env: remove trailing null-terminator from default path

This commit is contained in:
David Dorfman
2021-05-24 21:19:01 +03:00
committed by Fabian Homborg
parent 2b0b0fe042
commit f2448e3f0e

View File

@@ -244,7 +244,11 @@ static void setup_path() {
// _CS_PATH: colon-separated paths to find POSIX utilities
std::string cspath;
cspath.resize(confstr(_CS_PATH, nullptr, 0));
confstr(_CS_PATH, &cspath[0], cspath.length());
if (cspath.length() > 0) {
confstr(_CS_PATH, &cspath[0], cspath.length());
// remove the trailing null-terminator
cspath.resize(cspath.length() - 1);
}
#else
std::string cspath = "/usr/bin:/bin"; // I doubt this is even necessary
#endif