summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorderaadt <>2002-07-25 21:13:45 +0000
committerderaadt <>2002-07-25 21:13:45 +0000
commit38f8ca9fa51b59794faf1c8ca4e9b1b7c06eeb42 (patch)
treefd08b36ec9599d78879914d7983488f0e1e5155e /src
parentf60b3a80fab33686119eda8629a7cbe8319cc074 (diff)
downloadopenbsd-38f8ca9fa51b59794faf1c8ca4e9b1b7c06eeb42.tar.gz
openbsd-38f8ca9fa51b59794faf1c8ca4e9b1b7c06eeb42.tar.bz2
openbsd-38f8ca9fa51b59794faf1c8ca4e9b1b7c06eeb42.zip
kill more strcpy
Diffstat (limited to 'src')
-rw-r--r--src/lib/libc/net/getaddrinfo.c9
-rw-r--r--src/lib/libc/net/gethostnamadr.c6
-rw-r--r--src/lib/libc/net/getnetnamadr.c8
-rw-r--r--src/lib/libc/net/res_init.c8
4 files changed, 15 insertions, 16 deletions
diff --git a/src/lib/libc/net/getaddrinfo.c b/src/lib/libc/net/getaddrinfo.c
index 364bffedeb..744852bed7 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.40 2002/07/24 01:38:34 itojun Exp $ */ 1/* $OpenBSD: getaddrinfo.c,v 1.41 2002/07/25 21:13:45 deraadt 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/*
@@ -543,11 +543,11 @@ explore_fqdn(pai, hostname, servname, res)
543 } 543 }
544 544
545 if ((_res.options & RES_INIT) == 0 && res_init() == -1) 545 if ((_res.options & RES_INIT) == 0 && res_init() == -1)
546 strncpy(lookups, "f", sizeof lookups); 546 strlcpy(lookups, "f", sizeof lookups);
547 else { 547 else {
548 bcopy(_res.lookups, lookups, sizeof lookups); 548 bcopy(_res.lookups, lookups, sizeof lookups);
549 if (lookups[0] == '\0') 549 if (lookups[0] == '\0')
550 strncpy(lookups, "bf", sizeof lookups); 550 strlcpy(lookups, "bf", sizeof lookups);
551 } 551 }
552 552
553 for (i = 0; i < MAXDNSLUS && result == NULL && lookups[i]; i++) { 553 for (i = 0; i < MAXDNSLUS && result == NULL && lookups[i]; i++) {
@@ -818,10 +818,9 @@ get_canonname(pai, ai, str)
818 const char *str; 818 const char *str;
819{ 819{
820 if ((pai->ai_flags & AI_CANONNAME) != 0) { 820 if ((pai->ai_flags & AI_CANONNAME) != 0) {
821 ai->ai_canonname = (char *)malloc(strlen(str) + 1); 821 ai->ai_canonname = strdup(str);
822 if (ai->ai_canonname == NULL) 822 if (ai->ai_canonname == NULL)
823 return EAI_MEMORY; 823 return EAI_MEMORY;
824 strcpy(ai->ai_canonname, str);
825 } 824 }
826 return 0; 825 return 0;
827} 826}
diff --git a/src/lib/libc/net/gethostnamadr.c b/src/lib/libc/net/gethostnamadr.c
index 3049d576e1..f1aa448670 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)
55static char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.48 2002/06/26 06:00:53 itojun Exp $"; 55static char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.49 2002/07/25 21:13:45 deraadt 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>
@@ -614,7 +614,7 @@ gethostbyname2(name, af)
614 614
615 bcopy(_res.lookups, lookups, sizeof lookups); 615 bcopy(_res.lookups, lookups, sizeof lookups);
616 if (lookups[0] == '\0') 616 if (lookups[0] == '\0')
617 strncpy(lookups, "bf", sizeof lookups); 617 strlcpy(lookups, "bf", sizeof lookups);
618 618
619 hp = (struct hostent *)NULL; 619 hp = (struct hostent *)NULL;
620 for (i = 0; i < MAXDNSLUS && hp == NULL && lookups[i]; i++) { 620 for (i = 0; i < MAXDNSLUS && hp == NULL && lookups[i]; i++) {
@@ -719,7 +719,7 @@ gethostbyaddr(addr, len, af)
719 719
720 bcopy(_res.lookups, lookups, sizeof lookups); 720 bcopy(_res.lookups, lookups, sizeof lookups);
721 if (lookups[0] == '\0') 721 if (lookups[0] == '\0')
722 strncpy(lookups, "bf", sizeof lookups); 722 strlcpy(lookups, "bf", sizeof lookups);
723 723
724 hp = (struct hostent *)NULL; 724 hp = (struct hostent *)NULL;
725 for (i = 0; i < MAXDNSLUS && hp == NULL && lookups[i]; i++) { 725 for (i = 0; i < MAXDNSLUS && hp == NULL && lookups[i]; i++) {
diff --git a/src/lib/libc/net/getnetnamadr.c b/src/lib/libc/net/getnetnamadr.c
index a5a4200acf..44810337bd 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.16 2002/06/26 06:00:54 itojun Exp $ */ 1/* $OpenBSD: getnetnamadr.c,v 1.17 2002/07/25 21:13:45 deraadt 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";
77static char sccsid_[] = "from getnetnamadr.c 1.4 (Coimbra) 93/06/03"; 77static char sccsid_[] = "from getnetnamadr.c 1.4 (Coimbra) 93/06/03";
78static char rcsid[] = "$From: getnetnamadr.c,v 8.7 1996/08/05 08:31:35 vixie Exp $"; 78static char rcsid[] = "$From: getnetnamadr.c,v 8.7 1996/08/05 08:31:35 vixie Exp $";
79#else 79#else
80static char rcsid[] = "$OpenBSD: getnetnamadr.c,v 1.16 2002/06/26 06:00:54 itojun Exp $"; 80static char rcsid[] = "$OpenBSD: getnetnamadr.c,v 1.17 2002/07/25 21:13:45 deraadt Exp $";
81#endif 81#endif
82#endif /* LIBC_SCCS and not lint */ 82#endif /* LIBC_SCCS and not lint */
83 83
@@ -264,7 +264,7 @@ getnetbyaddr(net, net_type)
264 264
265 bcopy(_res.lookups, lookups, sizeof lookups); 265 bcopy(_res.lookups, lookups, sizeof lookups);
266 if (lookups[0] == '\0') 266 if (lookups[0] == '\0')
267 strncpy(lookups, "bf", sizeof lookups); 267 strlcpy(lookups, "bf", sizeof lookups);
268 268
269 for (i = 0; i < MAXDNSLUS && lookups[i]; i++) { 269 for (i = 0; i < MAXDNSLUS && lookups[i]; i++) {
270 switch (lookups[i]) { 270 switch (lookups[i]) {
@@ -347,7 +347,7 @@ getnetbyname(net)
347 347
348 bcopy(_res.lookups, lookups, sizeof lookups); 348 bcopy(_res.lookups, lookups, sizeof lookups);
349 if (lookups[0] == '\0') 349 if (lookups[0] == '\0')
350 strncpy(lookups, "bf", sizeof lookups); 350 strlcpy(lookups, "bf", sizeof lookups);
351 351
352 for (i = 0; i < MAXDNSLUS && lookups[i]; i++) { 352 for (i = 0; i < MAXDNSLUS && lookups[i]; i++) {
353 switch (lookups[i]) { 353 switch (lookups[i]) {
diff --git a/src/lib/libc/net/res_init.c b/src/lib/libc/net/res_init.c
index 099aa04e30..c55c7763a4 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.26 2002/06/27 10:14:02 itojun Exp $ */ 1/* $OpenBSD: res_init.c,v 1.27 2002/07/25 21:13:45 deraadt Exp $ */
2 2
3/* 3/*
4 * ++Copyright++ 1985, 1989, 1993 4 * ++Copyright++ 1985, 1989, 1993
@@ -64,7 +64,7 @@
64static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93"; 64static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
65static char rcsid[] = "$From: res_init.c,v 8.7 1996/09/28 06:51:07 vixie Exp $"; 65static char rcsid[] = "$From: res_init.c,v 8.7 1996/09/28 06:51:07 vixie Exp $";
66#else 66#else
67static char rcsid[] = "$OpenBSD: res_init.c,v 1.26 2002/06/27 10:14:02 itojun Exp $"; 67static char rcsid[] = "$OpenBSD: res_init.c,v 1.27 2002/07/25 21:13:45 deraadt Exp $";
68#endif 68#endif
69#endif /* LIBC_SCCS and not lint */ 69#endif /* LIBC_SCCS and not lint */
70 70
@@ -211,7 +211,7 @@ res_init()
211 _res.nscount = 1; 211 _res.nscount = 1;
212 _res.ndots = 1; 212 _res.ndots = 1;
213 _res.pfcode = 0; 213 _res.pfcode = 0;
214 strncpy(_res.lookups, "f", sizeof _res.lookups); 214 strlcpy(_res.lookups, "f", sizeof _res.lookups);
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) {
@@ -253,7 +253,7 @@ res_init()
253 line[sizeof(name) - 1] == '\t')) 253 line[sizeof(name) - 1] == '\t'))
254 254
255 if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) { 255 if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
256 strncpy(_res.lookups, "bf", sizeof _res.lookups); 256 strlcpy(_res.lookups, "bf", sizeof _res.lookups);
257 257
258 /* read the config file */ 258 /* read the config file */
259 buf[0] = '\0'; 259 buf[0] = '\0';