Stupid fix for zip_find_entry(). stable-2.0
authorRyan C. Gordon <icculus@icculus.org>
Wed, 22 Aug 2012 16:37:09 -0400
branchstable-2.0
changeset 1299 882cdbd7d0a3
parent 1298 3d9ab131709a
child 1302 2358ddb89d35
Stupid fix for zip_find_entry().
archivers/zip.c
--- a/archivers/zip.c	Mon Aug 20 14:39:46 2012 -0400
+++ b/archivers/zip.c	Wed Aug 22 16:37:09 2012 -0400
@@ -535,6 +535,8 @@
 
         else /* substring match...might be dir or entry or nothing. */
         {
+            int i;
+
             if (isDir != NULL)
             {
                 *isDir = (thispath[pathlen] == '/');
@@ -544,12 +546,27 @@
 
             if (thispath[pathlen] == '\0') /* found entry? */
                 return(&a[middle]);
-            /* adjust search params, try again. */
-            else if (thispath[pathlen] > '/')
-                hi = middle - 1;
-            else
-                lo = middle + 1;
-        } /* if */
+
+            /* substring match; search remaining space to find it... */
+            for (i = lo; i < hi; i++)
+            {
+                thispath = a[i].name;
+                if (strncmp(path, thispath, pathlen) == 0)
+                {
+                    if (isDir != NULL)
+                    {
+                        *isDir = (thispath[pathlen] == '/');
+                        if (*isDir)
+                            return(NULL);
+                    } /* if */
+
+                    if (thispath[pathlen] == '\0') /* found entry? */
+                        return(&a[i]);
+                } /* if */
+            } /* for */
+            break;
+
+        } /* else */
     } /* while */
 
     if (isDir != NULL)