about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2022-10-24 11:39:33 +0200
committerptitSeb <sebastien.chev@gmail.com>2022-10-24 11:39:33 +0200
commitd0b5c79b81ecdcf2df4833dece74449b90766fea (patch)
tree20aa1d787203fe0d8ab02380cec0102e4f247095
parent95622ca964ab37dff95e48d9d49c943df06b30d5 (diff)
downloadbox64-d0b5c79b81ecdcf2df4833dece74449b90766fea.tar.gz
box64-d0b5c79b81ecdcf2df4833dece74449b90766fea.zip
Use box_strdup instead of realpath for the string allocation to be safe
-rwxr-xr-xsrc/tools/fileutils.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/tools/fileutils.c b/src/tools/fileutils.c
index c9765740..af6634a0 100755
--- a/src/tools/fileutils.c
+++ b/src/tools/fileutils.c
@@ -57,8 +57,11 @@ char* ResolveFile(const char* filename, path_collection_t* paths)
         } else
             strcpy(p, paths->paths[i]);
         strcat(p, filename);
-        if(FileExist(p, IS_FILE))
-            return realpath(p, NULL);
+        if(FileExist(p, IS_FILE)) {
+            char p2[MAX_PATH];
+            realpath(p, p2);
+            return box_strdup(p2);
+        }
     }
 
     return box_strdup(filename); //NULL;