summaryrefslogtreecommitdiffstats
path: root/usr.sbin/traceroute
diff options
context:
space:
mode:
authorfenner <fenner@FreeBSD.org>1996-09-10 00:50:13 +0000
committerfenner <fenner@FreeBSD.org>1996-09-10 00:50:13 +0000
commitc5a6fcbc6ced2de2faae882dbb27a2694688937b (patch)
treec622097f44577c5db187320728a6ae81bdf7725b /usr.sbin/traceroute
parentb365ec4426ac100d90ece4ad8e1fd0a88760df26 (diff)
downloadFreeBSD-src-c5a6fcbc6ced2de2faae882dbb27a2694688937b.zip
FreeBSD-src-c5a6fcbc6ced2de2faae882dbb27a2694688937b.tar.gz
Change strcpy() to strncpy() in several places, and give gethostname()
the real buffer size. Note that the strncpy(domain, ...) doesn't need to be a strncpy(), since it is copying from itself to itself, but belts and suspenders don't hurt and this is not time-critical code. Fixes the half of PR bin/1581 that wasn't fixed in rev 1.7 Submitted by: Karl <karl@codebase.mcs.net>
Diffstat (limited to 'usr.sbin/traceroute')
-rw-r--r--usr.sbin/traceroute/traceroute.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.sbin/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c
index 8849dbb..ff4e3e8 100644
--- a/usr.sbin/traceroute/traceroute.c
+++ b/usr.sbin/traceroute/traceroute.c
@@ -1,6 +1,6 @@
#ifndef lint
static char *rcsid =
- "@(#)$Header: /home/ncvs/src/usr.sbin/traceroute/traceroute.c,v 1.9 1996/08/21 04:31:28 peter Exp $ (LBL)";
+ "@(#)$Header: /home/ncvs/src/usr.sbin/traceroute/traceroute.c,v 1.10 1996/08/21 05:59:19 peter Exp $ (LBL)";
#endif
/*
@@ -427,7 +427,7 @@ main(int argc, char **argv)
to->sin_family = AF_INET;
to->sin_addr.s_addr = inet_addr(av[0]);
if (to->sin_addr.s_addr != -1) {
- (void) strcpy(hnamebuf, av[0]);
+ (void) strncpy(hnamebuf, av[0], sizeof(hnamebuf));
hostname = hnamebuf;
} else {
hp = gethostbyname(av[0]);
@@ -867,9 +867,9 @@ inetname(struct in_addr in)
if (first && !nflag) {
first = 0;
- if (gethostname(domain, MAXHOSTNAMELEN) == 0 &&
+ if (gethostname(domain, sizeof(domain)) == 0 &&
(cp = strchr(domain, '.')))
- (void) strcpy(domain, cp + 1);
+ (void) strncpy(domain, cp + 1, sizeof(domain));
else
domain[0] = 0;
}
@@ -884,7 +884,7 @@ inetname(struct in_addr in)
}
}
if (cp)
- (void) strcpy(line, cp);
+ (void) strncpy(line, cp, sizeof(line));
else {
in.s_addr = ntohl(in.s_addr);
#define C(x) ((x) & 0xff)
OpenPOWER on IntegriCloud