Fix: let libc set length of resolved in realpath

This commit is contained in:
eater 2019-01-20 15:21:59 +01:00
parent ac1e2b4096
commit 3fb2c0658a
No known key found for this signature in database
GPG Key ID: 656785D50BE51C0A

View File

@ -221,6 +221,12 @@ static inline std::string canonicalizePath(const std::string& path) {
delete[] dest;
}
return result8;
#elif __gnu_linux__
char* realname = realpath(path.c_str(), NULL);
if (!realname) {
return "";
}
return std::string(realname);
#else
char realname[_POSIX_PATH_MAX];
if (realpath(path.c_str(), realname) == 0) {
@ -228,4 +234,4 @@ static inline std::string canonicalizePath(const std::string& path) {
}
return std::string(realname);
#endif
}
}