mirror of
https://github.com/LongSoft/UEFITool.git
synced 2025-05-09 13:52:01 -04:00
Remove PATH_MAX from realpath
POSIX.1-2008 ensures realpath() give a dynamically allocated buffer if NULL is passed, which avoids using PATH_MAX, which may be too large to fit in stack, or even undefined on some systems.
This commit is contained in:
parent
d61d759db2
commit
22bb757726
1 changed files with 8 additions and 4 deletions
|
@ -100,10 +100,14 @@ bool changeDirectory(const UString & dir)
|
|||
}
|
||||
|
||||
UString getAbsPath(const UString & path) {
|
||||
char abs[PATH_MAX] = {};
|
||||
char * abs = realpath(path.toLocal8Bit(), nullptr);
|
||||
// Last is a non-standard extension for non-existent files
|
||||
if (realpath(path.toLocal8Bit(), abs) || abs[0] != '\0')
|
||||
return UString(abs);
|
||||
return path;
|
||||
UString new_path;
|
||||
if (abs)
|
||||
new_path = UString(abs);
|
||||
else
|
||||
new_path = path;
|
||||
free(abs);
|
||||
return new_path;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue