summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2002-07-25 21:13:46 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2002-07-25 21:13:46 +0000
commitf25841e75fbcde2eb52dc5e8cd984c7f4f8c3884 (patch)
tree6bb95a6b3ea51e0ba258ec816b40a9971324ca29 /lib
parent10698ffae217c1d43c63989ff9364610d79831f7 (diff)
kill more strcpy
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/net/getaddrinfo.c9
-rw-r--r--lib/libc/net/gethostnamadr.c6
-rw-r--r--lib/libc/net/getnetnamadr.c8
-rw-r--r--lib/libc/net/res_init.c8
4 files changed, 15 insertions, 16 deletions
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
index 364bffedebd..744852bed7d 100644
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getaddrinfo.c,v 1.40 2002/07/24 01:38:34 itojun Exp $ */
+/* $OpenBSD: getaddrinfo.c,v 1.41 2002/07/25 21:13:45 deraadt Exp $ */
/* $KAME: getaddrinfo.c,v 1.31 2000/08/31 17:36:43 itojun Exp $ */
/*
@@ -543,11 +543,11 @@ explore_fqdn(pai, hostname, servname, res)
}
if ((_res.options & RES_INIT) == 0 && res_init() == -1)
- strncpy(lookups, "f", sizeof lookups);
+ strlcpy(lookups, "f", sizeof lookups);
else {
bcopy(_res.lookups, lookups, sizeof lookups);
if (lookups[0] == '\0')
- strncpy(lookups, "bf", sizeof lookups);
+ strlcpy(lookups, "bf", sizeof lookups);
}
for (i = 0; i < MAXDNSLUS && result == NULL && lookups[i]; i++) {
@@ -818,10 +818,9 @@ get_canonname(pai, ai, str)
const char *str;
{
if ((pai->ai_flags & AI_CANONNAME) != 0) {
- ai->ai_canonname = (char *)malloc(strlen(str) + 1);
+ ai->ai_canonname = strdup(str);
if (ai->ai_canonname == NULL)
return EAI_MEMORY;
- strcpy(ai->ai_canonname, str);
}
return 0;
}
diff --git a/lib/libc/net/gethostnamadr.c b/lib/libc/net/gethostnamadr.c
index 3049d576e10..f1aa4486706 100644
--- a/lib/libc/net/gethostnamadr.c
+++ b/lib/libc/net/gethostnamadr.c
@@ -52,7 +52,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.48 2002/06/26 06:00:53 itojun Exp $";
+static char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.49 2002/07/25 21:13:45 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -614,7 +614,7 @@ gethostbyname2(name, af)
bcopy(_res.lookups, lookups, sizeof lookups);
if (lookups[0] == '\0')
- strncpy(lookups, "bf", sizeof lookups);
+ strlcpy(lookups, "bf", sizeof lookups);
hp = (struct hostent *)NULL;
for (i = 0; i < MAXDNSLUS && hp == NULL && lookups[i]; i++) {
@@ -719,7 +719,7 @@ gethostbyaddr(addr, len, af)
bcopy(_res.lookups, lookups, sizeof lookups);
if (lookups[0] == '\0')
- strncpy(lookups, "bf", sizeof lookups);
+ strlcpy(lookups, "bf", sizeof lookups);
hp = (struct hostent *)NULL;
for (i = 0; i < MAXDNSLUS && hp == NULL && lookups[i]; i++) {
diff --git a/lib/libc/net/getnetnamadr.c b/lib/libc/net/getnetnamadr.c
index a5a4200acf1..44810337bde 100644
--- a/lib/libc/net/getnetnamadr.c
+++ b/lib/libc/net/getnetnamadr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getnetnamadr.c,v 1.16 2002/06/26 06:00:54 itojun Exp $ */
+/* $OpenBSD: getnetnamadr.c,v 1.17 2002/07/25 21:13:45 deraadt Exp $ */
/*
* Copyright (c) 1997, Jason Downs. All rights reserved.
@@ -77,7 +77,7 @@ static char sccsid[] = "@(#)getnetbyaddr.c 8.1 (Berkeley) 6/4/93";
static char sccsid_[] = "from getnetnamadr.c 1.4 (Coimbra) 93/06/03";
static char rcsid[] = "$From: getnetnamadr.c,v 8.7 1996/08/05 08:31:35 vixie Exp $";
#else
-static char rcsid[] = "$OpenBSD: getnetnamadr.c,v 1.16 2002/06/26 06:00:54 itojun Exp $";
+static char rcsid[] = "$OpenBSD: getnetnamadr.c,v 1.17 2002/07/25 21:13:45 deraadt Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -264,7 +264,7 @@ getnetbyaddr(net, net_type)
bcopy(_res.lookups, lookups, sizeof lookups);
if (lookups[0] == '\0')
- strncpy(lookups, "bf", sizeof lookups);
+ strlcpy(lookups, "bf", sizeof lookups);
for (i = 0; i < MAXDNSLUS && lookups[i]; i++) {
switch (lookups[i]) {
@@ -347,7 +347,7 @@ getnetbyname(net)
bcopy(_res.lookups, lookups, sizeof lookups);
if (lookups[0] == '\0')
- strncpy(lookups, "bf", sizeof lookups);
+ strlcpy(lookups, "bf", sizeof lookups);
for (i = 0; i < MAXDNSLUS && lookups[i]; i++) {
switch (lookups[i]) {
diff --git a/lib/libc/net/res_init.c b/lib/libc/net/res_init.c
index 099aa04e306..c55c7763a4e 100644
--- a/lib/libc/net/res_init.c
+++ b/lib/libc/net/res_init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_init.c,v 1.26 2002/06/27 10:14:02 itojun Exp $ */
+/* $OpenBSD: res_init.c,v 1.27 2002/07/25 21:13:45 deraadt Exp $ */
/*
* ++Copyright++ 1985, 1989, 1993
@@ -64,7 +64,7 @@
static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
static char rcsid[] = "$From: res_init.c,v 8.7 1996/09/28 06:51:07 vixie Exp $";
#else
-static char rcsid[] = "$OpenBSD: res_init.c,v 1.26 2002/06/27 10:14:02 itojun Exp $";
+static char rcsid[] = "$OpenBSD: res_init.c,v 1.27 2002/07/25 21:13:45 deraadt Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -211,7 +211,7 @@ res_init()
_res.nscount = 1;
_res.ndots = 1;
_res.pfcode = 0;
- strncpy(_res.lookups, "f", sizeof _res.lookups);
+ strlcpy(_res.lookups, "f", sizeof _res.lookups);
/* Allow user to override the local domain definition */
if (issetugid() == 0 && (cp = getenv("LOCALDOMAIN")) != NULL) {
@@ -253,7 +253,7 @@ res_init()
line[sizeof(name) - 1] == '\t'))
if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
- strncpy(_res.lookups, "bf", sizeof _res.lookups);
+ strlcpy(_res.lookups, "bf", sizeof _res.lookups);
/* read the config file */
buf[0] = '\0';