From 5fe652d7ad495642f82318ed520600311fa246ff Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 22 Aug 2012 16:37:09 -0400 Subject: [PATCH] Stupid fix for zip_find_entry(). --- archivers/zip.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/archivers/zip.c b/archivers/zip.c index 0b6297c8..0e65453a 100644 --- a/archivers/zip.c +++ b/archivers/zip.c @@ -535,6 +535,8 @@ static ZIPentry *zip_find_entry(ZIPinfo *info, const char *path, int *isDir) else /* substring match...might be dir or entry or nothing. */ { + int i; + if (isDir != NULL) { *isDir = (thispath[pathlen] == '/'); @@ -544,12 +546,27 @@ static ZIPentry *zip_find_entry(ZIPinfo *info, const char *path, int *isDir) 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)