瀏覽代碼

android: Don't ever enumerate absolute paths from the assets tree.

This could happen if opendir() failed for a reason other than the directory
missing (for example, `opendir("/")` fails with EACCES.

Reference Issue #15587.
Ryan C. Gordon 1 天之前
父節點
當前提交
e1fa336ac4
共有 1 個文件被更改,包括 5 次插入3 次删除
  1. 5 3
      src/filesystem/posix/SDL_sysfsops.c

+ 5 - 3
src/filesystem/posix/SDL_sysfsops.c

@@ -97,9 +97,11 @@ bool SDL_SYS_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback
     DIR *dir = opendir(pathwithsep);
     if (!dir) {
 #ifdef SDL_PLATFORM_ANDROID  // Maybe it's an asset... that didn't use an "assets://" URL?
-        const bool retval = Android_JNI_EnumerateAssetDirectory(pathwithsep + extralen, cb, userdata);
-        SDL_free(pathwithsep);
-        return retval;
+        if (*pathwithsep != '/') {  // don't fall back to asset tree for absolute paths, in case opendir() failed for other reasons, like opendir("/") returning EACCES.
+            const bool retval = Android_JNI_EnumerateAssetDirectory(pathwithsep + extralen, cb, userdata);
+            SDL_free(pathwithsep);
+            return retval;
+        }
 #endif
         SDL_free(pathwithsep);
         return SDL_SetError("Can't open directory: %s", strerror(errno));