Ver Fonte

If rejecting an archive for not matching a mount point, set an error state,
otherwise, PHYSFS_openRead could fail with a null error message.

Ryan C. Gordon há 21 anos atrás
pai
commit
38a1c7f559
1 ficheiros alterados com 5 adições e 5 exclusões
  1. 5 5
      physfs.c

+ 5 - 5
physfs.c

@@ -1241,12 +1241,12 @@ int __PHYSFS_verifySecurity(DirHandle *h, char *fname, int allowMissing)
         size_t mntpntlen = strlen(h->mountPoint);
         size_t mntpntlen = strlen(h->mountPoint);
         assert(mntpntlen > 1); /* root mount points should be NULL. */
         assert(mntpntlen > 1); /* root mount points should be NULL. */
         size_t len = strlen(fname);
         size_t len = strlen(fname);
-        if (len < mntpntlen)
-            return(0); /* not under the mountpoint, so skip this archive. */
-        if (strncmp(h->mountPoint, fname, mntpntlen) != 0)
-            return(0);  /* not under the mountpoint, so skip this archive. */
-
+        /* not under the mountpoint, so skip this archive. */
+        BAIL_IF_MACRO(len < mntpntlen, ERR_NO_SUCH_PATH, 0);
+        retval = strncmp(h->mountPoint, fname, mntpntlen);
+        BAIL_IF_MACRO(retval != 0, ERR_NO_SUCH_PATH, 0);
         fname += mntpntlen;  /* move to start of actual archive path. */
         fname += mntpntlen;  /* move to start of actual archive path. */
+        retval = 1;
     } /* if */
     } /* if */
 
 
     /* !!! FIXME: Can we ditch this malloc()? */
     /* !!! FIXME: Can we ditch this malloc()? */