1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:57:45 +00:00

LibC: Let strerror_r fail if errnum < 0

This commit is contained in:
Jelle Raaijmakers 2021-06-11 12:02:26 +02:00 committed by Andreas Kling
parent 90e229c9b5
commit 33c3c32a38

View file

@ -357,7 +357,7 @@ int sys_nerr = EMAXERRNO;
int strerror_r(int errnum, char* buf, size_t buflen)
{
auto saved_errno = errno;
if (errnum >= EMAXERRNO) {
if (errnum < 0 || errnum >= EMAXERRNO) {
auto rc = strlcpy(buf, "unknown error", buflen);
if (rc >= buflen)
dbgln("strerror_r(): Invalid error number '{}' specified and the output buffer is too small.", errnum);