1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 14:15:08 +00:00

LibC: Fix OOB access in strerror() with invalid input

Calling strerror() with a negative number should not access below the
error string array.

Found by running GCC in UE. :^)
This commit is contained in:
Andreas Kling 2020-11-14 11:23:39 +01:00
parent abe9cec612
commit a65e7db533

View file

@ -372,7 +372,7 @@ int sys_nerr = EMAXERRNO;
char* strerror(int errnum)
{
if (errnum >= EMAXERRNO) {
if (errnum < 0 || errnum >= EMAXERRNO) {
printf("strerror() missing string for errnum=%d\n", errnum);
return const_cast<char*>("Unknown error");
}