summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorrnordier <rnordier@FreeBSD.org>1998-10-29 11:39:39 +0000
committerrnordier <rnordier@FreeBSD.org>1998-10-29 11:39:39 +0000
commit042df0ac22d048ed5886fc6b52729ec9aba91aa9 (patch)
tree1f2452b3e7171281cc768c82ea231d3c22b344eb /lib
parentdce7995d53bddff5c6176438c538d03c93accdfa (diff)
downloadFreeBSD-src-042df0ac22d048ed5886fc6b52729ec9aba91aa9.zip
FreeBSD-src-042df0ac22d048ed5886fc6b52729ec9aba91aa9.tar.gz
The man page implies that the string argument to psignal() may be
NULL, in line with perror(3). However, the code presently checks only for a zero-length string. Check for both.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/psignal.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/libc/gen/psignal.c b/lib/libc/gen/psignal.c
index b7e7ab6..96eab9d 100644
--- a/lib/libc/gen/psignal.c
+++ b/lib/libc/gen/psignal.c
@@ -49,15 +49,13 @@ psignal(sig, s)
const char *s;
{
register const char *c;
- register int n;
if (sig < NSIG)
c = sys_siglist[sig];
else
c = "Unknown signal";
- n = strlen(s);
- if (n) {
- (void)write(STDERR_FILENO, s, n);
+ if (s != NULL && *s != '\0') {
+ (void)write(STDERR_FILENO, s, strlen(s));
(void)write(STDERR_FILENO, ": ", 2);
}
(void)write(STDERR_FILENO, c, strlen(c));
OpenPOWER on IntegriCloud