From 840cd4ce4ac8c781e7d35db2ed86d575a42c37e7 Mon Sep 17 00:00:00 2001 From: Anssi Hannula Date: Wed, 16 May 2012 00:14:49 +0300 Subject: [PATCH] fixed: CRarFile::Read() returning wrong data after some seek patterns Certain seek patterns on a file inside a non-compressed rar file can cause CmdExtract::UnstoreFile() to think that the destination buffer has been filled (as DestUnpSize counter, originally set to the file size, reaches zero). However, counting written bytes using DestUnpSize doesn't make sense for the UnpackToMemory codepath used for non-compressed rar files, as there can be seeks which can eventually cause more data to be read than what the actual file size was. The actual output buffer is internally handled by ComprDataIO. The check in UnstoreFile() will result in not all data being written to the destination buffer, causing CRarFile::Read() to return old stale data. Fix that by dropping the unnecessary DestUnpSize handling in UnpackToMemory codepath of CmdExtract::UnstoreFile(). --- lib/UnrarXLib/extract.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/UnrarXLib/extract.cpp b/lib/UnrarXLib/extract.cpp index da608572de055..ea9b8f9257fb4 100644 --- a/lib/UnrarXLib/extract.cpp +++ b/lib/UnrarXLib/extract.cpp @@ -859,10 +859,7 @@ void CmdExtract::UnstoreFile(ComprDataIO &DataIO,Int64 DestUnpSize) } if (Code > 0) { - Code=Code=0) - DestUnpSize-=Code; } else {