summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorderaadt <>2001-12-08 20:37:32 +0000
committerderaadt <>2001-12-08 20:37:32 +0000
commite5c0bcf0a1bf83998cce5c66cc9fb31068867108 (patch)
tree660a59fd59681a80031f717cfa55b43cf09b7c93
parent00a5b66e44967336be0fc76ef57bae611e741cde (diff)
downloadopenbsd-e5c0bcf0a1bf83998cce5c66cc9fb31068867108.tar.gz
openbsd-e5c0bcf0a1bf83998cce5c66cc9fb31068867108.tar.bz2
openbsd-e5c0bcf0a1bf83998cce5c66cc9fb31068867108.zip
when strerror() has an Unknown error, also set EINVAL
-rw-r--r--src/lib/libc/string/__strerror.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/libc/string/__strerror.c b/src/lib/libc/string/__strerror.c
index 04fdce580a..ae19ab3365 100644
--- a/src/lib/libc/string/__strerror.c
+++ b/src/lib/libc/string/__strerror.c
@@ -32,7 +32,7 @@
32 */ 32 */
33 33
34#if defined(LIBC_SCCS) && !defined(lint) 34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: __strerror.c,v 1.7 2001/06/27 00:58:56 lebel Exp $"; 35static char *rcsid = "$OpenBSD: __strerror.c,v 1.8 2001/12/08 20:37:32 deraadt Exp $";
36#endif /* LIBC_SCCS and not lint */ 36#endif /* LIBC_SCCS and not lint */
37 37
38#ifdef NLS 38#ifdef NLS
@@ -50,7 +50,8 @@ static char *rcsid = "$OpenBSD: __strerror.c,v 1.7 2001/06/27 00:58:56 lebel Exp
50#include <stdio.h> 50#include <stdio.h>
51#include <string.h> 51#include <string.h>
52 52
53static char *itoa(num) 53static char *
54itoa(num)
54 int num; 55 int num;
55{ 56{
56 static char buffer[11]; 57 static char buffer[11];
@@ -78,9 +79,10 @@ __strerror(num, buf)
78{ 79{
79#define UPREFIX "Unknown error: " 80#define UPREFIX "Unknown error: "
80 register unsigned int errnum; 81 register unsigned int errnum;
81
82#ifdef NLS 82#ifdef NLS
83 int save_errno;
83 nl_catd catd; 84 nl_catd catd;
85
84 catd = catopen("libc", 0); 86 catd = catopen("libc", 0);
85#endif 87#endif
86 88
@@ -99,10 +101,13 @@ __strerror(num, buf)
99 strcpy(buf, UPREFIX); 101 strcpy(buf, UPREFIX);
100#endif 102#endif
101 strncat(buf, itoa(errnum), NL_TEXTMAX-strlen(buf)-1); 103 strncat(buf, itoa(errnum), NL_TEXTMAX-strlen(buf)-1);
104 errno = EINVAL;
102 } 105 }
103 106
104#ifdef NLS 107#ifdef NLS
108 save_errno = errno;
105 catclose(catd); 109 catclose(catd);
110 errno = save_errno;
106#endif 111#endif
107 112
108 return buf; 113 return buf;