1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-12 02:30:30 +09: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
Notes: sideshowbarker 2024-07-19 02:28:37 +09:00

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");
}