util: Replace non-threadsafe strerror

Some uses of non-threadsafe `strerror` have snuck into the code since
they were removed in #4152. Add a wrapper `SysErrorString` for
thread-safe strerror alternatives and replace all uses of `strerror`
with this.
This commit is contained in:
laanwj
2022-04-20 16:17:19 +02:00
parent 4381681e55
commit 46971c6dbf
8 changed files with 59 additions and 17 deletions

View File

@@ -65,6 +65,7 @@
#include <util/strencodings.h>
#include <util/string.h>
#include <util/syscall_sandbox.h>
#include <util/syserror.h>
#include <util/system.h>
#include <util/thread.h>
#include <util/threadnames.h>
@@ -149,7 +150,7 @@ static fs::path GetPidFile(const ArgsManager& args)
#endif
return true;
} else {
return InitError(strprintf(_("Unable to create the PID file '%s': %s"), fs::PathToString(GetPidFile(args)), std::strerror(errno)));
return InitError(strprintf(_("Unable to create the PID file '%s': %s"), fs::PathToString(GetPidFile(args)), SysErrorString(errno)));
}
}