From e712a9ff58e39f4024451a1b2b0e04a5d78b713c Mon Sep 17 00:00:00 2001 From: gdr-ftp Date: Wed, 4 Feb 1998 15:16:19 +0000 Subject: [PATCH] - fixed a bug (found by Steve Reeves) where the check for an out-of-bounds errno was never catching illegal errnos, and thus could walk off the end of the message array. --- lib/libc/string/strerror.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libc/string/strerror.c b/lib/libc/string/strerror.c index ede6643..02b3b41 100644 --- a/lib/libc/string/strerror.c +++ b/lib/libc/string/strerror.c @@ -1,7 +1,7 @@ /* * Implementation by Devin Reade. * - * $Id: strerror.c,v 1.2 1997/09/21 06:23:08 gdr Exp $ + * $Id: strerror.c,v 1.3 1998/02/04 15:16:19 gdr-ftp Exp $ * * This file is formatted with tab stops every 8 columns. */ @@ -93,13 +93,13 @@ char * strerror (int errnum) { /* - * the size of buff must be greater than + * the size of buff must be no less than * strlen(sys_errlist[0]) + max number of digits in an int + 3 * == 13 + 5 + 3 == 21 */ static char buff[30]; - if (errnum > 0 || errnum < sys_nerr) { + if (errnum > 0 && errnum < sys_nerr) { return sys_errlist[errnum]; } sprintf(buff, "unknown error: %d", errnum);