diff options
Diffstat (limited to 'src/lib/libc/string/__strsignal.c')
-rw-r--r-- | src/lib/libc/string/__strsignal.c | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/lib/libc/string/__strsignal.c b/src/lib/libc/string/__strsignal.c index 1937e2d608..5bab3cd0af 100644 --- a/src/lib/libc/string/__strsignal.c +++ b/src/lib/libc/string/__strsignal.c | |||
@@ -10,11 +10,7 @@ | |||
10 | * 2. Redistributions in binary form must reproduce the above copyright | 10 | * 2. Redistributions in binary form must reproduce the above copyright |
11 | * notice, this list of conditions and the following disclaimer in the | 11 | * notice, this list of conditions and the following disclaimer in the |
12 | * documentation and/or other materials provided with the distribution. | 12 | * documentation and/or other materials provided with the distribution. |
13 | * 3. All advertising materials mentioning features or use of this software | 13 | * 3. Neither the name of the University nor the names of its contributors |
14 | * must display the following acknowledgement: | ||
15 | * This product includes software developed by the University of | ||
16 | * California, Berkeley and its contributors. | ||
17 | * 4. Neither the name of the University nor the names of its contributors | ||
18 | * may be used to endorse or promote products derived from this software | 14 | * may be used to endorse or promote products derived from this software |
19 | * without specific prior written permission. | 15 | * without specific prior written permission. |
20 | * | 16 | * |
@@ -32,8 +28,7 @@ | |||
32 | */ | 28 | */ |
33 | 29 | ||
34 | #if defined(LIBC_SCCS) && !defined(lint) | 30 | #if defined(LIBC_SCCS) && !defined(lint) |
35 | /*static char *sccsid = "from: @(#)strerror.c 5.6 (Berkeley) 5/4/91";*/ | 31 | static char *rcsid = "$OpenBSD: __strsignal.c,v 1.8 2003/06/02 20:18:38 millert Exp $"; |
36 | static char *rcsid = "$Id: __strsignal.c,v 1.1.1.1 1995/10/18 08:42:20 deraadt Exp $"; | ||
37 | #endif /* LIBC_SCCS and not lint */ | 32 | #endif /* LIBC_SCCS and not lint */ |
38 | 33 | ||
39 | #ifdef NLS | 34 | #ifdef NLS |
@@ -46,15 +41,31 @@ static char *rcsid = "$Id: __strsignal.c,v 1.1.1.1 1995/10/18 08:42:20 deraadt E | |||
46 | #define sys_siglist _sys_siglist | 41 | #define sys_siglist _sys_siglist |
47 | 42 | ||
48 | #include <stdio.h> | 43 | #include <stdio.h> |
44 | #include <limits.h> | ||
49 | #include <signal.h> | 45 | #include <signal.h> |
50 | #include <string.h> | 46 | #include <string.h> |
51 | 47 | ||
48 | static char *itoa(num) | ||
49 | int num; | ||
50 | { | ||
51 | static char buffer[11]; | ||
52 | char *p; | ||
53 | |||
54 | p = buffer + 4; | ||
55 | while (num >= 10) { | ||
56 | *--p = (num % 10) + '0'; | ||
57 | num /= 10; | ||
58 | } | ||
59 | *p = (num % 10) + '0'; | ||
60 | return p; | ||
61 | } | ||
62 | |||
52 | char * | 63 | char * |
53 | __strsignal(num, buf) | 64 | __strsignal(num, buf) |
54 | int num; | 65 | int num; |
55 | char *buf; | 66 | char *buf; |
56 | { | 67 | { |
57 | #define UPREFIX "Unknown signal: %u" | 68 | #define UPREFIX "Unknown signal: " |
58 | register unsigned int signum; | 69 | register unsigned int signum; |
59 | 70 | ||
60 | #ifdef NLS | 71 | #ifdef NLS |
@@ -65,17 +76,18 @@ __strsignal(num, buf) | |||
65 | signum = num; /* convert to unsigned */ | 76 | signum = num; /* convert to unsigned */ |
66 | if (signum < NSIG) { | 77 | if (signum < NSIG) { |
67 | #ifdef NLS | 78 | #ifdef NLS |
68 | strcpy(buf, catgets(catd, 2, signum, | 79 | strlcpy(buf, catgets(catd, 2, signum, |
69 | (char *)sys_siglist[signum])); | 80 | (char *)sys_siglist[signum]), NL_TEXTMAX); |
70 | #else | 81 | #else |
71 | return((char *)sys_siglist[signum]); | 82 | return((char *)sys_siglist[signum]); |
72 | #endif | 83 | #endif |
73 | } else { | 84 | } else { |
74 | #ifdef NLS | 85 | #ifdef NLS |
75 | sprintf(buf, catgets(catd, 1, 0xffff, UPREFIX), signum); | 86 | strlcpy(buf, catgets(catd, 1, 0xffff, UPREFIX), NL_TEXTMAX); |
76 | #else | 87 | #else |
77 | sprintf(buf, UPREFIX, signum); | 88 | strlcpy(buf, UPREFIX, NL_TEXTMAX); |
78 | #endif | 89 | #endif |
90 | strlcat(buf, itoa(signum), NL_TEXTMAX); | ||
79 | } | 91 | } |
80 | 92 | ||
81 | #ifdef NLS | 93 | #ifdef NLS |