From fdcf0a6f638e1d45818d64b554dd30fc5278935b Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 19 Sep 2021 12:57:14 +0200 Subject: [PATCH 1/2] fix deflation of epub files with abnormal zip header if unpSize is detected correctly but packSize is not, use packSize provided by central director instead --- crengine/src/lvstream/lvzipdecodestream.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crengine/src/lvstream/lvzipdecodestream.cpp b/crengine/src/lvstream/lvzipdecodestream.cpp index b334af2c8..86c1a585d 100644 --- a/crengine/src/lvstream/lvzipdecodestream.cpp +++ b/crengine/src/lvstream/lvzipdecodestream.cpp @@ -380,11 +380,11 @@ LVStream *LVZipDecodeStream::Create(LVStreamRef stream, lvpos_t pos, lString32 n if ( stream->Seek( pos, LVSEEK_SET, NULL )!=LVERR_OK ) return NULL; #endif - if ( packSize==0 && unpSize==0 ) { - // Can happen when local header does not carry these sizes - // Use the ones provided that come from zip central directory - packSize = srcPackSize; - unpSize = srcUnpSize; + { + // When local header does not carry these sizes, use the ones + // that come from zip central directory + if ( packSize==0 ) packSize = srcPackSize; + if ( unpSize==0 ) unpSize = srcUnpSize; } if ((lvpos_t)(pos + packSize) > (lvpos_t)stream->GetSize()) return NULL; From 1d09da8ce6eea7ad61f0a2518b1b88a817777a8e Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 19 Sep 2021 18:03:38 +0200 Subject: [PATCH 2/2] code reformatting --- crengine/src/lvstream/lvzipdecodestream.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crengine/src/lvstream/lvzipdecodestream.cpp b/crengine/src/lvstream/lvzipdecodestream.cpp index 86c1a585d..2fa4c31ef 100644 --- a/crengine/src/lvstream/lvzipdecodestream.cpp +++ b/crengine/src/lvstream/lvzipdecodestream.cpp @@ -380,12 +380,12 @@ LVStream *LVZipDecodeStream::Create(LVStreamRef stream, lvpos_t pos, lString32 n if ( stream->Seek( pos, LVSEEK_SET, NULL )!=LVERR_OK ) return NULL; #endif - { - // When local header does not carry these sizes, use the ones - // that come from zip central directory - if ( packSize==0 ) packSize = srcPackSize; - if ( unpSize==0 ) unpSize = srcUnpSize; - } + + // When local header does not carry these sizes, use the ones + // that come from zip central directory + if ( packSize==0 ) packSize = srcPackSize; + if ( unpSize==0 ) unpSize = srcUnpSize; + if ((lvpos_t)(pos + packSize) > (lvpos_t)stream->GetSize()) return NULL; if (hdr.getMethod() == 0) {