diff options
author | lebel <lebel@cvs.openbsd.org> | 2001-06-27 00:58:58 +0000 |
---|---|---|
committer | lebel <lebel@cvs.openbsd.org> | 2001-06-27 00:58:58 +0000 |
commit | 8af9ac2691950c45385aecf7c502a16c3c11db86 (patch) | |
tree | 2b4161da48e1261faa9895ae08bd1fcdf3be38a3 /lib/libc/string | |
parent | c5355883f033c52fa97b73febb89e80adf21cbbd (diff) |
use strlcpy vs strncpy+a[len-1]='\0'. millert@ ok.
Diffstat (limited to 'lib/libc/string')
-rw-r--r-- | lib/libc/string/__strerror.c | 10 | ||||
-rw-r--r-- | lib/libc/string/__strsignal.c | 10 |
2 files changed, 8 insertions, 12 deletions
diff --git a/lib/libc/string/__strerror.c b/lib/libc/string/__strerror.c index 9c023f8a534..04fdce580a4 100644 --- a/lib/libc/string/__strerror.c +++ b/lib/libc/string/__strerror.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: __strerror.c,v 1.6 1996/09/25 08:17:30 deraadt Exp $"; +static char *rcsid = "$OpenBSD: __strerror.c,v 1.7 2001/06/27 00:58:56 lebel Exp $"; #endif /* LIBC_SCCS and not lint */ #ifdef NLS @@ -87,16 +87,14 @@ __strerror(num, buf) errnum = num; /* convert to unsigned */ if (errnum < sys_nerr) { #ifdef NLS - strncpy(buf, catgets(catd, 1, errnum, - (char *)sys_errlist[errnum]), NL_TEXTMAX-1); - buf[NL_TEXTMAX - 1] = '\0'; + strlcpy(buf, catgets(catd, 1, errnum, + (char *)sys_errlist[errnum]), NL_TEXTMAX); #else return(sys_errlist[errnum]); #endif } else { #ifdef NLS - strncpy(buf, catgets(catd, 1, 0xffff, UPREFIX), NL_TEXTMAX-1); - buf[NL_TEXTMAX - 1] = '\0'; + strlcpy(buf, catgets(catd, 1, 0xffff, UPREFIX), NL_TEXTMAX); #else strcpy(buf, UPREFIX); #endif diff --git a/lib/libc/string/__strsignal.c b/lib/libc/string/__strsignal.c index ae0df72cd36..4ca5bad3c0f 100644 --- a/lib/libc/string/__strsignal.c +++ b/lib/libc/string/__strsignal.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: __strsignal.c,v 1.5 1996/09/25 13:19:01 deraadt Exp $"; +static char *rcsid = "$OpenBSD: __strsignal.c,v 1.6 2001/06/27 00:58:56 lebel Exp $"; #endif /* LIBC_SCCS and not lint */ #ifdef NLS @@ -80,16 +80,14 @@ __strsignal(num, buf) signum = num; /* convert to unsigned */ if (signum < NSIG) { #ifdef NLS - strncpy(buf, catgets(catd, 2, signum, - (char *)sys_siglist[signum]), NL_TEXTMAX-1); - buf[NL_TEXTMAX-1] = '\0'; + strlcpy(buf, catgets(catd, 2, signum, + (char *)sys_siglist[signum]), NL_TEXTMAX); #else return((char *)sys_siglist[signum]); #endif } else { #ifdef NLS - strncpy(buf, catgets(catd, 1, 0xffff, UPREFIX), NL_TEXTMAX-1); - buf[NL_TEXTMAX-1] = '\0'; + strlcpy(buf, catgets(catd, 1, 0xffff, UPREFIX), NL_TEXTMAX); #else strcpy(buf, UPREFIX); #endif |