fix: _psCreateFolder creates the dir without relying on realpath side effects
This commit is contained in:
@@ -120,14 +120,11 @@ void _psCreateFolder(const char *path)
|
||||
CloseHandle(hfle);
|
||||
#else
|
||||
struct stat info;
|
||||
char fullpath[PATH_MAX];
|
||||
realpath(path, fullpath);
|
||||
|
||||
if (lstat(fullpath, &info) != 0) {
|
||||
if (errno == ENOENT || (errno != EACCES && !S_ISDIR(info.st_mode))) {
|
||||
mkdir(fullpath, 0755);
|
||||
}
|
||||
}
|
||||
// realpath() can't resolve the folder before it exists and leaves its output
|
||||
// buffer unspecified when it returns NULL, so create the folder from the path
|
||||
// as given instead of trusting the resolved buffer.
|
||||
if (lstat(path, &info) != 0 && errno == ENOENT)
|
||||
mkdir(path, 0755);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user