Skip to content

Commit

Permalink
Stupid fix for zip_find_entry().
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Aug 22, 2012
1 parent 5af008e commit 5fe652d
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions archivers/zip.c
Expand Up @@ -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] == '/');
Expand All @@ -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)
Expand Down

0 comments on commit 5fe652d

Please sign in to comment.