From ba402d79ff98416ac427d18eae4b5c1d1b6928df Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Fri, 21 Aug 2015 13:42:45 +0300 Subject: [PATCH] [fbreader] Handle slightly broken zip files Only DEFLATED entries can have EXT descriptor, ignore this flag for STORED entries. --- .../zlibrary/core/src/filesystem/zip/ZLZipHeader.cpp | 4 +++- .../fbreader/zlibrary/core/src/filesystem/zip/ZLZipHeader.h | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/fbreader/fbreader/zlibrary/core/src/filesystem/zip/ZLZipHeader.cpp b/fbreader/fbreader/zlibrary/core/src/filesystem/zip/ZLZipHeader.cpp index 6436126..5531b97 100644 --- a/fbreader/fbreader/zlibrary/core/src/filesystem/zip/ZLZipHeader.cpp +++ b/fbreader/fbreader/zlibrary/core/src/filesystem/zip/ZLZipHeader.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2004-2010 Geometer Plus + * Copyright (C) 2015 Slava Monich * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -63,7 +64,8 @@ void ZLZipHeader::skipEntry(ZLInputStream &stream, ZLZipHeader &header) { default: break; case SignatureLocalFile: - if (header.Flags & 0x08) { + // Only DEFLATED entries can have EXT descriptor + if (header.CompressionMethod != ZLZipHeader::MethodStored && (header.Flags & 0x08)) { stream.seek(header.ExtraLength, false); ZLZDecompressor decompressor((size_t)-1); size_t size; diff --git a/fbreader/fbreader/zlibrary/core/src/filesystem/zip/ZLZipHeader.h b/fbreader/fbreader/zlibrary/core/src/filesystem/zip/ZLZipHeader.h index cf53a42..cdcc425 100644 --- a/fbreader/fbreader/zlibrary/core/src/filesystem/zip/ZLZipHeader.h +++ b/fbreader/fbreader/zlibrary/core/src/filesystem/zip/ZLZipHeader.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2004-2010 Geometer Plus + * Copyright (C) 2015 Slava Monich * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,6 +27,11 @@ struct ZLZipHeader { static const unsigned long SignatureLocalFile; static const unsigned long SignatureData; + enum { + MethodStored = 0, + MethodDeflated = 8 + }; + unsigned long Signature; unsigned short Version; unsigned short Flags;