From fc6d85b2f476d6bfead21466a794be166bd477bb Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 5 May 2007 05:53:03 +0000 Subject: [PATCH] Backport from devbranch: Fixed zip archiver: could do bogus seek if a small, non-zip file got put through isArchive(). --- CHANGELOG | 2 ++ archivers/zip.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 529fea50..e3867f09 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,8 @@ -- stuff in the stable-1.0 branch, backported from 2.0.0 dev branch, etc --- +05052007 - Fixed zip archiver: could do bogus seek if a small, non-zip file + got put through isArchive(). 04022007 - Fixed Doxygen comment. 03312007 - Moved DIR archiver to start of the list, so we don't have to have every other archiver fail to open a directory as a file before diff --git a/archivers/zip.c b/archivers/zip.c index ec252618..4ba1297d 100644 --- a/archivers/zip.c +++ b/archivers/zip.c @@ -489,6 +489,8 @@ static PHYSFS_sint64 zip_find_end_of_central_dir(void *in, PHYSFS_sint64 *len) break; filepos -= (maxread - 4); + if (filepos < 0) + filepos = 0; } /* while */ BAIL_IF_MACRO(!found, ERR_NOT_AN_ARCHIVE, -1);