Skip to content

Commit

Permalink
fixed: CRarFile::Read() returning wrong data after some seek patterns
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
anssih committed May 16, 2012
1 parent 617a0ff commit 840cd4c
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions lib/UnrarXLib/extract.cpp
Expand Up @@ -859,10 +859,7 @@ void CmdExtract::UnstoreFile(ComprDataIO &DataIO,Int64 DestUnpSize)
}
if (Code > 0)
{
Code=Code<DestUnpSize ? Code:int64to32(DestUnpSize);
DataIO.UnpWrite(&Buffer[0],Code);
if (DestUnpSize>=0)
DestUnpSize-=Code;
}
else
{
Expand Down

0 comments on commit 840cd4c

Please sign in to comment.