From 872cf03f26c2801ae6c3008ce5fa0d7856f5f85d Mon Sep 17 00:00:00 2001 From: Kacper Date: Sun, 14 Dec 2025 18:10:13 +0100 Subject: libc: implement err/warn functions --- lib/libc/string/strerror.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/libc/string') diff --git a/lib/libc/string/strerror.c b/lib/libc/string/strerror.c index c0a73146..2d3ea611 100644 --- a/lib/libc/string/strerror.c +++ b/lib/libc/string/strerror.c @@ -104,6 +104,12 @@ char *strerror(int errnum) [EKEYREJECTED] = "Key was rejected by service", }; + if (errnum < 0 || (size_t)errnum >= sizeof(table) / sizeof(table[0]) || + !table[errnum]) { + errno = EINVAL; + return NULL; + } + return table[errnum]; } -- cgit v1.2.3