Guard against unsigned ickyness for files less than 1024 bytes

Change-Id: I360fb8db35b36194c4f7ae08c93126e2a7bda853
This commit is contained in:
Tor Lillqvist
2013-02-19 17:38:19 +02:00
parent a062799bd6
commit 95e6a0885e

View File

@@ -219,8 +219,14 @@ static bool findCentralDirectoryEnd(NSFileHandle *file)
[file seekToFileOffset: (fileLength - 4)];
unsigned long long limit;
if (fileLength > 1024)
limit = fileLength - 1024;
else
limit = 0;
unsigned long long offset;
while ((offset = [file offsetInFile]) > 0 && offset >= fileLength - 1024)
while ((offset = [file offsetInFile]) > limit)
{
unsigned signature = readInt(file);
if (signature == CDIR_END_SIG)