diff options
Diffstat (limited to 'src/user/lib/string/strerror.c')
-rw-r--r-- | src/user/lib/string/strerror.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/user/lib/string/strerror.c b/src/user/lib/string/strerror.c index 1f5fc29..c838299 100644 --- a/src/user/lib/string/strerror.c +++ b/src/user/lib/string/strerror.c @@ -7,5 +7,7 @@ static const char *errstr[] = { }; char *strerror(int n) { - return (char*)(errstr[n] ? errstr[n] : "unknown error"); + if (0 <= n && n * sizeof(*errstr) < sizeof(errstr) && errstr[n]) + return (char*)errstr[n]; + return "unknown error"; } |