diff options
| author | lebel <> | 2001-06-27 00:58:56 +0000 |
|---|---|---|
| committer | lebel <> | 2001-06-27 00:58:56 +0000 |
| commit | ba6f70d7550cc513151c4bb719659d4775a9efff (patch) | |
| tree | 267e8c115af6744d1fab5a015c06458ba2befdab /src/lib/libc | |
| parent | c18bed276b8f6877a6111a6c03185f0025220031 (diff) | |
| download | openbsd-ba6f70d7550cc513151c4bb719659d4775a9efff.tar.gz openbsd-ba6f70d7550cc513151c4bb719659d4775a9efff.tar.bz2 openbsd-ba6f70d7550cc513151c4bb719659d4775a9efff.zip | |
use strlcpy vs strncpy+a[len-1]='\0'. millert@ ok.
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libc/crypt/crypt.c | 7 | ||||
| -rw-r--r-- | src/lib/libc/net/ethers.c | 7 | ||||
| -rw-r--r-- | src/lib/libc/net/getaddrinfo.c | 5 | ||||
| -rw-r--r-- | src/lib/libc/net/gethostnamadr.c | 8 | ||||
| -rw-r--r-- | src/lib/libc/net/getifaddrs.c | 5 | ||||
| -rw-r--r-- | src/lib/libc/net/getnetnamadr.c | 17 | ||||
| -rw-r--r-- | src/lib/libc/net/ipx_addr.c | 5 | ||||
| -rw-r--r-- | src/lib/libc/net/ns_addr.c | 5 | ||||
| -rw-r--r-- | src/lib/libc/net/rcmd.c | 5 | ||||
| -rw-r--r-- | src/lib/libc/net/res_init.c | 18 | ||||
| -rw-r--r-- | src/lib/libc/net/res_query.c | 8 | ||||
| -rw-r--r-- | src/lib/libc/stdlib/realpath.c | 5 | ||||
| -rw-r--r-- | src/lib/libc/string/__strerror.c | 10 | ||||
| -rw-r--r-- | src/lib/libc/string/__strsignal.c | 10 |
14 files changed, 47 insertions, 68 deletions
diff --git a/src/lib/libc/crypt/crypt.c b/src/lib/libc/crypt/crypt.c index 8fd319a4f3..d1a342c178 100644 --- a/src/lib/libc/crypt/crypt.c +++ b/src/lib/libc/crypt/crypt.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: crypt.c,v 1.13 1998/03/22 19:01:18 niklas Exp $ */ | 1 | /* $OpenBSD: crypt.c,v 1.14 2001/06/27 00:58:53 lebel Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * FreeSec: libcrypt | 4 | * FreeSec: libcrypt |
| @@ -52,7 +52,7 @@ | |||
| 52 | */ | 52 | */ |
| 53 | 53 | ||
| 54 | #if defined(LIBC_SCCS) && !defined(lint) | 54 | #if defined(LIBC_SCCS) && !defined(lint) |
| 55 | static char rcsid[] = "$OpenBSD: crypt.c,v 1.13 1998/03/22 19:01:18 niklas Exp $"; | 55 | static char rcsid[] = "$OpenBSD: crypt.c,v 1.14 2001/06/27 00:58:53 lebel Exp $"; |
| 56 | #endif /* LIBC_SCCS and not lint */ | 56 | #endif /* LIBC_SCCS and not lint */ |
| 57 | 57 | ||
| 58 | #include <sys/types.h> | 58 | #include <sys/types.h> |
| @@ -650,7 +650,7 @@ crypt(key, setting) | |||
| 650 | if (des_setkey((u_char *) keybuf)) | 650 | if (des_setkey((u_char *) keybuf)) |
| 651 | return(NULL); | 651 | return(NULL); |
| 652 | } | 652 | } |
| 653 | strncpy((char *)output, setting, 9); | 653 | strlcpy((char *)output, setting, 10); |
| 654 | 654 | ||
| 655 | /* | 655 | /* |
| 656 | * Double check that we weren't given a short setting. | 656 | * Double check that we weren't given a short setting. |
| @@ -659,7 +659,6 @@ crypt(key, setting) | |||
| 659 | * Just make sure the output string doesn't have an extra | 659 | * Just make sure the output string doesn't have an extra |
| 660 | * NUL in it. | 660 | * NUL in it. |
| 661 | */ | 661 | */ |
| 662 | output[9] = '\0'; | ||
| 663 | p = output + strlen((const char *)output); | 662 | p = output + strlen((const char *)output); |
| 664 | } else { | 663 | } else { |
| 665 | /* | 664 | /* |
diff --git a/src/lib/libc/net/ethers.c b/src/lib/libc/net/ethers.c index 1124e43253..2c8328a9ba 100644 --- a/src/lib/libc/net/ethers.c +++ b/src/lib/libc/net/ethers.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ethers.c,v 1.11 2000/08/22 19:04:41 deraadt Exp $ */ | 1 | /* $OpenBSD: ethers.c,v 1.12 2001/06/27 00:58:54 lebel Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> | 4 | * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> |
| @@ -34,7 +34,7 @@ | |||
| 34 | */ | 34 | */ |
| 35 | 35 | ||
| 36 | #if defined(LIBC_SCCS) && !defined(lint) | 36 | #if defined(LIBC_SCCS) && !defined(lint) |
| 37 | static char rcsid[] = "$OpenBSD: ethers.c,v 1.11 2000/08/22 19:04:41 deraadt Exp $"; | 37 | static char rcsid[] = "$OpenBSD: ethers.c,v 1.12 2001/06/27 00:58:54 lebel Exp $"; |
| 38 | #endif /* LIBC_SCCS and not lint */ | 38 | #endif /* LIBC_SCCS and not lint */ |
| 39 | 39 | ||
| 40 | #include <sys/types.h> | 40 | #include <sys/types.h> |
| @@ -263,8 +263,7 @@ ether_line(line, e, hostname) | |||
| 263 | n = strcspn(p, " \t\n"); | 263 | n = strcspn(p, " \t\n"); |
| 264 | if (n >= MAXHOSTNAMELEN) | 264 | if (n >= MAXHOSTNAMELEN) |
| 265 | goto bad; | 265 | goto bad; |
| 266 | (void)strncpy(hostname, p, n); | 266 | strlcpy(hostname, p, n + 1); |
| 267 | hostname[n] = '\0'; | ||
| 268 | return (0); | 267 | return (0); |
| 269 | 268 | ||
| 270 | bad: | 269 | bad: |
diff --git a/src/lib/libc/net/getaddrinfo.c b/src/lib/libc/net/getaddrinfo.c index 0a0b112589..cc313c5c6a 100644 --- a/src/lib/libc/net/getaddrinfo.c +++ b/src/lib/libc/net/getaddrinfo.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: getaddrinfo.c,v 1.28 2001/06/11 10:05:58 itojun Exp $ */ | 1 | /* $OpenBSD: getaddrinfo.c,v 1.29 2001/06/27 00:58:54 lebel Exp $ */ |
| 2 | /* $KAME: getaddrinfo.c,v 1.31 2000/08/31 17:36:43 itojun Exp $ */ | 2 | /* $KAME: getaddrinfo.c,v 1.31 2000/08/31 17:36:43 itojun Exp $ */ |
| 3 | 3 | ||
| 4 | /* | 4 | /* |
| @@ -1797,8 +1797,7 @@ res_querydomainN(name, domain, target) | |||
| 1797 | return (-1); | 1797 | return (-1); |
| 1798 | } | 1798 | } |
| 1799 | if (n > 0 && name[--n] == '.') { | 1799 | if (n > 0 && name[--n] == '.') { |
| 1800 | strncpy(nbuf, name, n); | 1800 | strlcpy(nbuf, name, n + 1); |
| 1801 | nbuf[n] = '\0'; | ||
| 1802 | } else | 1801 | } else |
| 1803 | longname = name; | 1802 | longname = name; |
| 1804 | } else { | 1803 | } else { |
diff --git a/src/lib/libc/net/gethostnamadr.c b/src/lib/libc/net/gethostnamadr.c index 33c9643f70..d7d6c621cf 100644 --- a/src/lib/libc/net/gethostnamadr.c +++ b/src/lib/libc/net/gethostnamadr.c | |||
| @@ -52,7 +52,7 @@ | |||
| 52 | */ | 52 | */ |
| 53 | 53 | ||
| 54 | #if defined(LIBC_SCCS) && !defined(lint) | 54 | #if defined(LIBC_SCCS) && !defined(lint) |
| 55 | static char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.42 2000/07/30 14:07:14 itojun Exp $"; | 55 | static char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.43 2001/06/27 00:58:55 lebel Exp $"; |
| 56 | #endif /* LIBC_SCCS and not lint */ | 56 | #endif /* LIBC_SCCS and not lint */ |
| 57 | 57 | ||
| 58 | #include <sys/param.h> | 58 | #include <sys/param.h> |
| @@ -574,8 +574,7 @@ gethostbyname2(name, af) | |||
| 574 | h_errno = HOST_NOT_FOUND; | 574 | h_errno = HOST_NOT_FOUND; |
| 575 | return (NULL); | 575 | return (NULL); |
| 576 | } | 576 | } |
| 577 | strncpy(hostbuf, name, MAXHOSTNAMELEN-1); | 577 | strlcpy(hostbuf, name, MAXHOSTNAMELEN); |
| 578 | hostbuf[MAXHOSTNAMELEN-1] = '\0'; | ||
| 579 | bp = hostbuf + MAXHOSTNAMELEN; | 578 | bp = hostbuf + MAXHOSTNAMELEN; |
| 580 | len = sizeof hostbuf - MAXHOSTNAMELEN; | 579 | len = sizeof hostbuf - MAXHOSTNAMELEN; |
| 581 | host.h_name = hostbuf; | 580 | host.h_name = hostbuf; |
| @@ -607,8 +606,7 @@ gethostbyname2(name, af) | |||
| 607 | h_errno = HOST_NOT_FOUND; | 606 | h_errno = HOST_NOT_FOUND; |
| 608 | return (NULL); | 607 | return (NULL); |
| 609 | } | 608 | } |
| 610 | strncpy(hostbuf, name, MAXHOSTNAMELEN-1); | 609 | strlcpy(hostbuf, name, MAXHOSTNAMELEN); |
| 611 | hostbuf[MAXHOSTNAMELEN-1] = '\0'; | ||
| 612 | bp = hostbuf + MAXHOSTNAMELEN; | 610 | bp = hostbuf + MAXHOSTNAMELEN; |
| 613 | len = sizeof hostbuf - MAXHOSTNAMELEN; | 611 | len = sizeof hostbuf - MAXHOSTNAMELEN; |
| 614 | host.h_name = hostbuf; | 612 | host.h_name = hostbuf; |
diff --git a/src/lib/libc/net/getifaddrs.c b/src/lib/libc/net/getifaddrs.c index 29348cd492..5be334cb6c 100644 --- a/src/lib/libc/net/getifaddrs.c +++ b/src/lib/libc/net/getifaddrs.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: getifaddrs.c,v 1.3 2000/11/24 08:26:47 itojun Exp $ */ | 1 | /* $OpenBSD: getifaddrs.c,v 1.4 2001/06/27 00:58:55 lebel Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 1995, 1999 | 4 | * Copyright (c) 1995, 1999 |
| @@ -353,8 +353,7 @@ getifaddrs(struct ifaddrs **pif) | |||
| 353 | struct sockaddr *sa; | 353 | struct sockaddr *sa; |
| 354 | 354 | ||
| 355 | ift->ifa_name = names; | 355 | ift->ifa_name = names; |
| 356 | names[sizeof(ifr->ifr_name)] = 0; | 356 | strlcpy(names, ifr->ifr_name, sizeof(ifr->ifr_name)); |
| 357 | strncpy(names, ifr->ifr_name, sizeof(ifr->ifr_name)); | ||
| 358 | while (*names++) | 357 | while (*names++) |
| 359 | ; | 358 | ; |
| 360 | 359 | ||
diff --git a/src/lib/libc/net/getnetnamadr.c b/src/lib/libc/net/getnetnamadr.c index 0ebc77b656..f755cd9b14 100644 --- a/src/lib/libc/net/getnetnamadr.c +++ b/src/lib/libc/net/getnetnamadr.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: getnetnamadr.c,v 1.13 1999/06/04 06:38:10 niklas Exp $ */ | 1 | /* $OpenBSD: getnetnamadr.c,v 1.14 2001/06/27 00:58:55 lebel Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 1997, Jason Downs. All rights reserved. | 4 | * Copyright (c) 1997, Jason Downs. All rights reserved. |
| @@ -77,7 +77,7 @@ static char sccsid[] = "@(#)getnetbyaddr.c 8.1 (Berkeley) 6/4/93"; | |||
| 77 | static char sccsid_[] = "from getnetnamadr.c 1.4 (Coimbra) 93/06/03"; | 77 | static char sccsid_[] = "from getnetnamadr.c 1.4 (Coimbra) 93/06/03"; |
| 78 | static char rcsid[] = "$From: getnetnamadr.c,v 8.7 1996/08/05 08:31:35 vixie Exp $"; | 78 | static char rcsid[] = "$From: getnetnamadr.c,v 8.7 1996/08/05 08:31:35 vixie Exp $"; |
| 79 | #else | 79 | #else |
| 80 | static char rcsid[] = "$OpenBSD: getnetnamadr.c,v 1.13 1999/06/04 06:38:10 niklas Exp $"; | 80 | static char rcsid[] = "$OpenBSD: getnetnamadr.c,v 1.14 2001/06/27 00:58:55 lebel Exp $"; |
| 81 | #endif | 81 | #endif |
| 82 | #endif /* LIBC_SCCS and not lint */ | 82 | #endif /* LIBC_SCCS and not lint */ |
| 83 | 83 | ||
| @@ -184,8 +184,7 @@ getnetanswer(answer, anslen, net_i) | |||
| 184 | break; | 184 | break; |
| 185 | cp += n; | 185 | cp += n; |
| 186 | ans[0] = '\0'; | 186 | ans[0] = '\0'; |
| 187 | (void)strncpy(&ans[0], bp, sizeof ans-1); | 187 | strlcpy(&ans[0], bp, sizeof ans); |
| 188 | ans[sizeof ans-1] = '\0'; | ||
| 189 | GETSHORT(type, cp); | 188 | GETSHORT(type, cp); |
| 190 | GETSHORT(class, cp); | 189 | GETSHORT(class, cp); |
| 191 | cp += INT32SZ; /* TTL */ | 190 | cp += INT32SZ; /* TTL */ |
| @@ -226,10 +225,9 @@ getnetanswer(answer, anslen, net_i) | |||
| 226 | ; | 225 | ; |
| 227 | if (nchar != 1 || *in != '0' || flag) { | 226 | if (nchar != 1 || *in != '0' || flag) { |
| 228 | flag = 1; | 227 | flag = 1; |
| 229 | (void)strncpy(paux1, | 228 | strlcpy(paux1, |
| 230 | (i==0) ? in : in-1, | 229 | (i==0) ? in : in-1, |
| 231 | (i==0) ?nchar : nchar+1); | 230 | (i==0) ? nchar+1 : nchar+2); |
| 232 | paux1[(i==0) ? nchar : nchar+1] = '\0'; | ||
| 233 | pauxt = paux2; | 231 | pauxt = paux2; |
| 234 | paux2 = strcat(paux1, paux2); | 232 | paux2 = strcat(paux1, paux2); |
| 235 | paux1 = pauxt; | 233 | paux1 = pauxt; |
| @@ -358,8 +356,7 @@ getnetbyname(net) | |||
| 358 | break; | 356 | break; |
| 359 | #endif /* YP */ | 357 | #endif /* YP */ |
| 360 | case 'b': | 358 | case 'b': |
| 361 | strncpy(qbuf, net, sizeof qbuf-1); | 359 | strlcpy(qbuf, net, sizeof qbuf); |
| 362 | qbuf[sizeof qbuf-1] = '\0'; | ||
| 363 | anslen = res_search(qbuf, C_IN, T_PTR, (u_char *)&buf, | 360 | anslen = res_search(qbuf, C_IN, T_PTR, (u_char *)&buf, |
| 364 | sizeof(buf)); | 361 | sizeof(buf)); |
| 365 | if (anslen < 0) { | 362 | if (anslen < 0) { |
diff --git a/src/lib/libc/net/ipx_addr.c b/src/lib/libc/net/ipx_addr.c index 9c9fe651cd..0d225e281b 100644 --- a/src/lib/libc/net/ipx_addr.c +++ b/src/lib/libc/net/ipx_addr.c | |||
| @@ -37,7 +37,7 @@ | |||
| 37 | */ | 37 | */ |
| 38 | 38 | ||
| 39 | #if defined(LIBC_SCCS) && !defined(lint) | 39 | #if defined(LIBC_SCCS) && !defined(lint) |
| 40 | static char rcsid[] = "$OpenBSD: ipx_addr.c,v 1.4 2001/01/04 21:45:30 todd Exp $"; | 40 | static char rcsid[] = "$OpenBSD: ipx_addr.c,v 1.5 2001/06/27 00:58:55 lebel Exp $"; |
| 41 | #endif /* LIBC_SCCS and not lint */ | 41 | #endif /* LIBC_SCCS and not lint */ |
| 42 | 42 | ||
| 43 | #include <sys/param.h> | 43 | #include <sys/param.h> |
| @@ -57,8 +57,7 @@ ipx_addr(name) | |||
| 57 | char *hostname, *socketname, *cp; | 57 | char *hostname, *socketname, *cp; |
| 58 | char buf[50]; | 58 | char buf[50]; |
| 59 | 59 | ||
| 60 | (void)strncpy(buf, name, sizeof(buf) - 1); | 60 | strlcpy(buf, name, sizeof(buf)); |
| 61 | buf[sizeof(buf) - 1] = '\0'; | ||
| 62 | 61 | ||
| 63 | /* | 62 | /* |
| 64 | * First, figure out what he intends as a field separtor. | 63 | * First, figure out what he intends as a field separtor. |
diff --git a/src/lib/libc/net/ns_addr.c b/src/lib/libc/net/ns_addr.c index e44ac21195..7dcc988afe 100644 --- a/src/lib/libc/net/ns_addr.c +++ b/src/lib/libc/net/ns_addr.c | |||
| @@ -35,7 +35,7 @@ | |||
| 35 | */ | 35 | */ |
| 36 | 36 | ||
| 37 | #if defined(LIBC_SCCS) && !defined(lint) | 37 | #if defined(LIBC_SCCS) && !defined(lint) |
| 38 | static char rcsid[] = "$OpenBSD: ns_addr.c,v 1.5 2001/01/04 21:45:31 todd Exp $"; | 38 | static char rcsid[] = "$OpenBSD: ns_addr.c,v 1.6 2001/06/27 00:58:55 lebel Exp $"; |
| 39 | #endif /* LIBC_SCCS and not lint */ | 39 | #endif /* LIBC_SCCS and not lint */ |
| 40 | 40 | ||
| 41 | #include <sys/param.h> | 41 | #include <sys/param.h> |
| @@ -56,8 +56,7 @@ ns_addr(name) | |||
| 56 | char *hostname, *socketname, *cp; | 56 | char *hostname, *socketname, *cp; |
| 57 | char buf[50]; | 57 | char buf[50]; |
| 58 | 58 | ||
| 59 | (void)strncpy(buf, name, sizeof(buf) - 1); | 59 | strlcpy(buf, name, sizeof(buf)); |
| 60 | buf[sizeof(buf) - 1] = '\0'; | ||
| 61 | 60 | ||
| 62 | /* | 61 | /* |
| 63 | * First, figure out what he intends as a field separtor. | 62 | * First, figure out what he intends as a field separtor. |
diff --git a/src/lib/libc/net/rcmd.c b/src/lib/libc/net/rcmd.c index 2ad3530c87..1439fff061 100644 --- a/src/lib/libc/net/rcmd.c +++ b/src/lib/libc/net/rcmd.c | |||
| @@ -34,7 +34,7 @@ | |||
| 34 | */ | 34 | */ |
| 35 | 35 | ||
| 36 | #if defined(LIBC_SCCS) && !defined(lint) | 36 | #if defined(LIBC_SCCS) && !defined(lint) |
| 37 | static char *rcsid = "$OpenBSD: rcmd.c,v 1.37 2001/02/10 21:55:07 millert Exp $"; | 37 | static char *rcsid = "$OpenBSD: rcmd.c,v 1.38 2001/06/27 00:58:55 lebel Exp $"; |
| 38 | #endif /* LIBC_SCCS and not lint */ | 38 | #endif /* LIBC_SCCS and not lint */ |
| 39 | 39 | ||
| 40 | #include <sys/param.h> | 40 | #include <sys/param.h> |
| @@ -125,8 +125,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) | |||
| 125 | return (-1); | 125 | return (-1); |
| 126 | } | 126 | } |
| 127 | if (res->ai_canonname) { | 127 | if (res->ai_canonname) { |
| 128 | strncpy(hbuf, res->ai_canonname, sizeof(hbuf) - 1); | 128 | strlcpy(hbuf, res->ai_canonname, sizeof(hbuf)); |
| 129 | hbuf[sizeof(hbuf) - 1] = '\0'; | ||
| 130 | *ahost = hbuf; | 129 | *ahost = hbuf; |
| 131 | } else | 130 | } else |
| 132 | ; /*XXX*/ | 131 | ; /*XXX*/ |
diff --git a/src/lib/libc/net/res_init.c b/src/lib/libc/net/res_init.c index c44539604a..5134323f4e 100644 --- a/src/lib/libc/net/res_init.c +++ b/src/lib/libc/net/res_init.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: res_init.c,v 1.21 2001/06/11 10:06:00 itojun Exp $ */ | 1 | /* $OpenBSD: res_init.c,v 1.22 2001/06/27 00:58:55 lebel Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * ++Copyright++ 1985, 1989, 1993 | 4 | * ++Copyright++ 1985, 1989, 1993 |
| @@ -64,7 +64,7 @@ | |||
| 64 | static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93"; | 64 | static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93"; |
| 65 | static char rcsid[] = "$From: res_init.c,v 8.7 1996/09/28 06:51:07 vixie Exp $"; | 65 | static char rcsid[] = "$From: res_init.c,v 8.7 1996/09/28 06:51:07 vixie Exp $"; |
| 66 | #else | 66 | #else |
| 67 | static char rcsid[] = "$OpenBSD: res_init.c,v 1.21 2001/06/11 10:06:00 itojun Exp $"; | 67 | static char rcsid[] = "$OpenBSD: res_init.c,v 1.22 2001/06/27 00:58:55 lebel Exp $"; |
| 68 | #endif | 68 | #endif |
| 69 | #endif /* LIBC_SCCS and not lint */ | 69 | #endif /* LIBC_SCCS and not lint */ |
| 70 | 70 | ||
| @@ -215,8 +215,7 @@ res_init() | |||
| 215 | 215 | ||
| 216 | /* Allow user to override the local domain definition */ | 216 | /* Allow user to override the local domain definition */ |
| 217 | if (issetugid() == 0 && (cp = getenv("LOCALDOMAIN")) != NULL) { | 217 | if (issetugid() == 0 && (cp = getenv("LOCALDOMAIN")) != NULL) { |
| 218 | (void)strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1); | 218 | strlcpy(_res.defdname, cp, sizeof(_res.defdname)); |
| 219 | _res.defdname[sizeof(_res.defdname) - 1] = '\0'; | ||
| 220 | haveenv++; | 219 | haveenv++; |
| 221 | 220 | ||
| 222 | /* | 221 | /* |
| @@ -278,8 +277,7 @@ res_init() | |||
| 278 | cp++; | 277 | cp++; |
| 279 | if ((*cp == '\0') || (*cp == '\n')) | 278 | if ((*cp == '\0') || (*cp == '\n')) |
| 280 | continue; | 279 | continue; |
| 281 | strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1); | 280 | strlcpy(_res.defdname, cp, sizeof(_res.defdname)); |
| 282 | _res.defdname[sizeof(_res.defdname) - 1] = '\0'; | ||
| 283 | if ((cp = strpbrk(_res.defdname, " \t\n")) != NULL) | 281 | if ((cp = strpbrk(_res.defdname, " \t\n")) != NULL) |
| 284 | *cp = '\0'; | 282 | *cp = '\0'; |
| 285 | havesearch = 0; | 283 | havesearch = 0; |
| @@ -321,8 +319,7 @@ res_init() | |||
| 321 | cp++; | 319 | cp++; |
| 322 | if ((*cp == '\0') || (*cp == '\n')) | 320 | if ((*cp == '\0') || (*cp == '\n')) |
| 323 | continue; | 321 | continue; |
| 324 | strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1); | 322 | strlcpy(_res.defdname, cp, sizeof(_res.defdname)); |
| 325 | _res.defdname[sizeof(_res.defdname) - 1] = '\0'; | ||
| 326 | if ((cp = strchr(_res.defdname, '\n')) != NULL) | 323 | if ((cp = strchr(_res.defdname, '\n')) != NULL) |
| 327 | *cp = '\0'; | 324 | *cp = '\0'; |
| 328 | /* | 325 | /* |
| @@ -520,9 +517,8 @@ res_init() | |||
| 520 | gethostname(buf, sizeof(_res.defdname) - 1) == 0 && | 517 | gethostname(buf, sizeof(_res.defdname) - 1) == 0 && |
| 521 | (cp = strchr(buf, '.')) != NULL) | 518 | (cp = strchr(buf, '.')) != NULL) |
| 522 | { | 519 | { |
| 523 | strncpy(_res.defdname, cp + 1, | 520 | strlcpy(_res.defdname, cp + 1, |
| 524 | sizeof(_res.defdname) - 1); | 521 | sizeof(_res.defdname)); |
| 525 | _res.defdname[sizeof(_res.defdname) - 1] = '\0'; | ||
| 526 | } | 522 | } |
| 527 | 523 | ||
| 528 | /* find components of local domain that might be searched */ | 524 | /* find components of local domain that might be searched */ |
diff --git a/src/lib/libc/net/res_query.c b/src/lib/libc/net/res_query.c index 433e80f648..db76821fc6 100644 --- a/src/lib/libc/net/res_query.c +++ b/src/lib/libc/net/res_query.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: res_query.c,v 1.14 2001/06/11 10:06:01 itojun Exp $ */ | 1 | /* $OpenBSD: res_query.c,v 1.15 2001/06/27 00:58:55 lebel Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * ++Copyright++ 1988, 1993 | 4 | * ++Copyright++ 1988, 1993 |
| @@ -60,7 +60,7 @@ | |||
| 60 | static char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93"; | 60 | static char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93"; |
| 61 | static char rcsid[] = "$From: res_query.c,v 8.9 1996/09/22 00:13:28 vixie Exp $"; | 61 | static char rcsid[] = "$From: res_query.c,v 8.9 1996/09/22 00:13:28 vixie Exp $"; |
| 62 | #else | 62 | #else |
| 63 | static char rcsid[] = "$OpenBSD: res_query.c,v 1.14 2001/06/11 10:06:01 itojun Exp $"; | 63 | static char rcsid[] = "$OpenBSD: res_query.c,v 1.15 2001/06/27 00:58:55 lebel Exp $"; |
| 64 | #endif | 64 | #endif |
| 65 | #endif /* LIBC_SCCS and not lint */ | 65 | #endif /* LIBC_SCCS and not lint */ |
| 66 | 66 | ||
| @@ -390,8 +390,8 @@ hostalias(name) | |||
| 390 | break; | 390 | break; |
| 391 | for (cp2 = cp1 + 1; *cp2 && !isspace(*cp2); ++cp2) | 391 | for (cp2 = cp1 + 1; *cp2 && !isspace(*cp2); ++cp2) |
| 392 | ; | 392 | ; |
| 393 | strncpy(abuf, cp1, sizeof(abuf) - 1); | 393 | *cp2 = '\0'; |
| 394 | abuf[sizeof(abuf) - 1] = *cp2 = '\0'; | 394 | strlcpy(abuf, cp1, sizeof(abuf)); |
| 395 | fclose(fp); | 395 | fclose(fp); |
| 396 | return (abuf); | 396 | return (abuf); |
| 397 | } | 397 | } |
diff --git a/src/lib/libc/stdlib/realpath.c b/src/lib/libc/stdlib/realpath.c index 0288601464..a6195c1dcb 100644 --- a/src/lib/libc/stdlib/realpath.c +++ b/src/lib/libc/stdlib/realpath.c | |||
| @@ -35,7 +35,7 @@ | |||
| 35 | */ | 35 | */ |
| 36 | 36 | ||
| 37 | #if defined(LIBC_SCCS) && !defined(lint) | 37 | #if defined(LIBC_SCCS) && !defined(lint) |
| 38 | static char *rcsid = "$OpenBSD: realpath.c,v 1.4 1998/05/18 09:55:19 deraadt Exp $"; | 38 | static char *rcsid = "$OpenBSD: realpath.c,v 1.5 2001/06/27 00:58:56 lebel Exp $"; |
| 39 | #endif /* LIBC_SCCS and not lint */ | 39 | #endif /* LIBC_SCCS and not lint */ |
| 40 | 40 | ||
| 41 | #include <sys/param.h> | 41 | #include <sys/param.h> |
| @@ -78,8 +78,7 @@ realpath(path, resolved) | |||
| 78 | * if it is a directory, then change to that directory. | 78 | * if it is a directory, then change to that directory. |
| 79 | * get the current directory name and append the basename. | 79 | * get the current directory name and append the basename. |
| 80 | */ | 80 | */ |
| 81 | (void)strncpy(resolved, path, MAXPATHLEN - 1); | 81 | strlcpy(resolved, path, MAXPATHLEN); |
| 82 | resolved[MAXPATHLEN - 1] = '\0'; | ||
| 83 | loop: | 82 | loop: |
| 84 | q = strrchr(resolved, '/'); | 83 | q = strrchr(resolved, '/'); |
| 85 | if (q != NULL) { | 84 | if (q != NULL) { |
diff --git a/src/lib/libc/string/__strerror.c b/src/lib/libc/string/__strerror.c index 9c023f8a53..04fdce580a 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) |
| 35 | static char *rcsid = "$OpenBSD: __strerror.c,v 1.6 1996/09/25 08:17:30 deraadt Exp $"; | 35 | static char *rcsid = "$OpenBSD: __strerror.c,v 1.7 2001/06/27 00:58:56 lebel Exp $"; |
| 36 | #endif /* LIBC_SCCS and not lint */ | 36 | #endif /* LIBC_SCCS and not lint */ |
| 37 | 37 | ||
| 38 | #ifdef NLS | 38 | #ifdef NLS |
| @@ -87,16 +87,14 @@ __strerror(num, buf) | |||
| 87 | errnum = num; /* convert to unsigned */ | 87 | errnum = num; /* convert to unsigned */ |
| 88 | if (errnum < sys_nerr) { | 88 | if (errnum < sys_nerr) { |
| 89 | #ifdef NLS | 89 | #ifdef NLS |
| 90 | strncpy(buf, catgets(catd, 1, errnum, | 90 | strlcpy(buf, catgets(catd, 1, errnum, |
| 91 | (char *)sys_errlist[errnum]), NL_TEXTMAX-1); | 91 | (char *)sys_errlist[errnum]), NL_TEXTMAX); |
| 92 | buf[NL_TEXTMAX - 1] = '\0'; | ||
| 93 | #else | 92 | #else |
| 94 | return(sys_errlist[errnum]); | 93 | return(sys_errlist[errnum]); |
| 95 | #endif | 94 | #endif |
| 96 | } else { | 95 | } else { |
| 97 | #ifdef NLS | 96 | #ifdef NLS |
| 98 | strncpy(buf, catgets(catd, 1, 0xffff, UPREFIX), NL_TEXTMAX-1); | 97 | strlcpy(buf, catgets(catd, 1, 0xffff, UPREFIX), NL_TEXTMAX); |
| 99 | buf[NL_TEXTMAX - 1] = '\0'; | ||
| 100 | #else | 98 | #else |
| 101 | strcpy(buf, UPREFIX); | 99 | strcpy(buf, UPREFIX); |
| 102 | #endif | 100 | #endif |
diff --git a/src/lib/libc/string/__strsignal.c b/src/lib/libc/string/__strsignal.c index ae0df72cd3..4ca5bad3c0 100644 --- a/src/lib/libc/string/__strsignal.c +++ b/src/lib/libc/string/__strsignal.c | |||
| @@ -32,7 +32,7 @@ | |||
| 32 | */ | 32 | */ |
| 33 | 33 | ||
| 34 | #if defined(LIBC_SCCS) && !defined(lint) | 34 | #if defined(LIBC_SCCS) && !defined(lint) |
| 35 | static char *rcsid = "$OpenBSD: __strsignal.c,v 1.5 1996/09/25 13:19:01 deraadt Exp $"; | 35 | static char *rcsid = "$OpenBSD: __strsignal.c,v 1.6 2001/06/27 00:58:56 lebel Exp $"; |
| 36 | #endif /* LIBC_SCCS and not lint */ | 36 | #endif /* LIBC_SCCS and not lint */ |
| 37 | 37 | ||
| 38 | #ifdef NLS | 38 | #ifdef NLS |
| @@ -80,16 +80,14 @@ __strsignal(num, buf) | |||
| 80 | signum = num; /* convert to unsigned */ | 80 | signum = num; /* convert to unsigned */ |
| 81 | if (signum < NSIG) { | 81 | if (signum < NSIG) { |
| 82 | #ifdef NLS | 82 | #ifdef NLS |
| 83 | strncpy(buf, catgets(catd, 2, signum, | 83 | strlcpy(buf, catgets(catd, 2, signum, |
| 84 | (char *)sys_siglist[signum]), NL_TEXTMAX-1); | 84 | (char *)sys_siglist[signum]), NL_TEXTMAX); |
| 85 | buf[NL_TEXTMAX-1] = '\0'; | ||
| 86 | #else | 85 | #else |
| 87 | return((char *)sys_siglist[signum]); | 86 | return((char *)sys_siglist[signum]); |
| 88 | #endif | 87 | #endif |
| 89 | } else { | 88 | } else { |
| 90 | #ifdef NLS | 89 | #ifdef NLS |
| 91 | strncpy(buf, catgets(catd, 1, 0xffff, UPREFIX), NL_TEXTMAX-1); | 90 | strlcpy(buf, catgets(catd, 1, 0xffff, UPREFIX), NL_TEXTMAX); |
| 92 | buf[NL_TEXTMAX-1] = '\0'; | ||
| 93 | #else | 91 | #else |
| 94 | strcpy(buf, UPREFIX); | 92 | strcpy(buf, UPREFIX); |
| 95 | #endif | 93 | #endif |
