Unix filesystem: long-path safety

This commit is contained in:
envision3d
2026-09-19 12:49:34 -05:00
parent 66f128cc8e
commit d6f513a25c
+12 -9
View File
@@ -89,8 +89,9 @@ bool DeleteUnixPathTree(const char* path)
continue;
// Determinate a full path of an entry
char full_path[256];
ASSERT(pathLength + strlen(entry->d_name) < ARRAY_COUNT(full_path));
char full_path[4096];
if (pathLength + strlen(entry->d_name) + 2 > ARRAY_COUNT(full_path))
continue;
strcpy(full_path, path);
strcat(full_path, "/");
strcat(full_path, entry->d_name);
@@ -199,8 +200,9 @@ bool UnixFileSystem::GetChildDirectories(Array<String>& results, const String& p
continue;
// Determinate a full path of an entry
char fullPath[256];
ASSERT(pathLength + strlen(entry->d_name) < ARRAY_COUNT(fullPath));
char fullPath[4096];
if (pathLength + strlen(entry->d_name) + 2 > ARRAY_COUNT(fullPath))
continue;
strcpy(fullPath, pathStr);
strcat(fullPath, "/");
strcat(fullPath, entry->d_name);
@@ -353,9 +355,9 @@ bool UnixFileSystem::getFilesFromDirectoryTop(Array<String>& results, const char
continue;
// Determinate a full path of an entry
char fullPath[256];
const int32 pathLength = strlen(entry->d_name);
ASSERT(pathLength + strlen(entry->d_name) < ARRAY_COUNT(fullPath));
char fullPath[4096];
if (pathLength + strlen(entry->d_name) + 2 > ARRAY_COUNT(fullPath))
continue;
strcpy(fullPath, path);
strcat(fullPath, "/");
strcat(fullPath, entry->d_name);
@@ -419,8 +421,9 @@ bool UnixFileSystem::getFilesFromDirectoryAll(Array<String>& results, const char
continue;
// Determinate a full path of an entry
char full_path[256];
ASSERT(pathLength + strlen(entry->d_name) < ARRAY_COUNT(full_path));
char full_path[4096];
if (pathLength + strlen(entry->d_name) + 2 > ARRAY_COUNT(full_path))
continue;
strcpy(full_path, path);
strcat(full_path, "/");
strcat(full_path, entry->d_name);