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/net/gethostnamadr.c | |
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 'src/lib/libc/net/gethostnamadr.c')
-rw-r--r-- | src/lib/libc/net/gethostnamadr.c | 8 |
1 files changed, 3 insertions, 5 deletions
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; |