From: Jorg Walter
authorRyan C. Gordon <icculus@icculus.org>
Sat, 23 Jul 2005 21:46:07 +0000
changeset 715 d6bf881b6e1e
parent 714 03c2e2ee0905
child 717 ae8bc9888553
From: Jorg Walter To: icculus@clutteredmind.org Subject: Bug in zip archiver Date: Sat, 23 Jul 2005 22:19:09 +0200 Hi! PhysFS has a bug in the ZIP archive module, function zip_find_start_of_dir. Upon encountering a substring match, rc is set to a wrong value. The fix is simple: swap both assignments like this: [patch below --Ed.] Some additional info for testing: Symptoms when you encounter this bug: A dir is reported as empty although it has files in it; prerequisites or encountering it: two dirs, one a substring of another, like "data/txt" and "data/txt2", laid out in a way so that variable "middle" points to a file in txt2 at some point during zip_find_start_of_dir By the way, if you're interested in where PhysFS is used: I found this bug while writing a patch for DOSBox (http://dosbox.sourceforge.net) to support ZIP files. And I'd love to see that enhanced PHYSFS_mount syntax in an official release soon *hint* ;);)
CHANGELOG
CREDITS
archivers/zip.c
--- a/CHANGELOG	Thu Jul 21 18:10:17 2005 +0000
+++ b/CHANGELOG	Sat Jul 23 21:46:07 2005 +0000
@@ -2,6 +2,7 @@
  * CHANGELOG.
  */
 
+07232005 - Fixed bug in zip archiver (thanks, Jörg Walter!).
 07212005 - Patched to compile on OS/2 again.
 07132005 - Updated zlib to 1.2.2, and patched it for this security hole:
            http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-2096
--- a/CREDITS	Thu Jul 21 18:10:17 2005 +0000
+++ b/CREDITS	Sat Jul 23 21:46:07 2005 +0000
@@ -87,6 +87,9 @@
 Mingw support:
     Matze Braun
 
+Bug fixes:
+    Jörg Walter
+
 Other stuff:
     Your name here! Patches go to icculus@clutteredmind.org ...
 
--- a/archivers/zip.c	Thu Jul 21 18:10:17 2005 +0000
+++ b/archivers/zip.c	Sat Jul 23 21:46:07 2005 +0000
@@ -1146,9 +1146,9 @@
         if (rc == 0)
         {
             char ch = name[dlen];
-            if (ch < '/') /* make sure this isn't just a substr match. */
+            if ('/' < ch) /* make sure this isn't just a substr match. */
                 rc = -1;
-            else if (ch > '/')
+            else if ('/' > ch)
                 rc = 1;
             else 
             {