Fix symlink filtering for enumeration under a virtual mount point.
authorRyan C. Gordon <icculus@icculus.org>
Mon, 14 Aug 2017 11:43:18 -0400
changeset 1575 be0a87101943
parent 1574 87100b3836cd
child 1576 b25da658b8ee
Fix symlink filtering for enumeration under a virtual mount point.
src/physfs.c
--- a/src/physfs.c	Mon Aug 14 03:06:42 2017 -0400
+++ b/src/physfs.c	Mon Aug 14 11:43:18 2017 -0400
@@ -2348,6 +2348,7 @@
     PHYSFS_EnumerateCallback callback;
     void *callbackData;
     DirHandle *dirhandle;
+    const char *arcfname;
     PHYSFS_ErrorCode errcode;
 } SymlinkFilterData;
 
@@ -2357,8 +2358,9 @@
 {
     SymlinkFilterData *data = (SymlinkFilterData *) _data;
     const DirHandle *dh = data->dirhandle;
+    const char *arcfname = data->arcfname;
     PHYSFS_Stat statbuf;
-    const char *trimmedDir = (*origdir == '/') ? (origdir+1) : origdir;
+    const char *trimmedDir = (*arcfname == '/') ? (arcfname + 1) : arcfname;
     const size_t slen = strlen(trimmedDir) + strlen(fname) + 2;
     char *path = (char *) __PHYSFS_smallAlloc(slen);
     int retval = 1;
@@ -2434,6 +2436,7 @@
                 if ((!allowSymLinks) && (i->funcs->info.supportsSymlinks))
                 {
                     filterdata.dirhandle = i;
+                    filterdata.arcfname = arcfname;
                     filterdata.errcode = PHYSFS_ERR_OK;
                     retval = i->funcs->enumerate(i->opaque, arcfname,
                                                  enumCallbackFilterSymLinks,