Avoid using savestr() on something which will later be passed to

free().  Raised as a potential security issue on bugtraq.  No actual
exploits known.
This commit is contained in:
sommerfeld 2000-09-30 12:44:37 +00:00
parent 5b88ba6121
commit 802499fd1c
1 changed files with 4 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: traceroute.c,v 1.39 2000/01/31 14:26:40 itojun Exp $ */
/* $NetBSD: traceroute.c,v 1.40 2000/09/30 12:44:37 sommerfeld Exp $ */
/*
* Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997
@ -29,7 +29,7 @@ static const char rcsid[] =
#else
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997\n\
The Regents of the University of California. All rights reserved.\n");
__RCSID("$NetBSD: traceroute.c,v 1.39 2000/01/31 14:26:40 itojun Exp $");
__RCSID("$NetBSD: traceroute.c,v 1.40 2000/09/30 12:44:37 sommerfeld Exp $");
#endif
#endif
@ -1446,7 +1446,7 @@ gethostinfo(register char *hostname)
exit(1);
}
if (inet_aton(hostname, &addr) != 0) {
hi->name = savestr(hostname);
hi->name = strdup(hostname);
hi->n = 1;
hi->addrs = calloc(1, sizeof(hi->addrs[0]));
if (hi->addrs == NULL) {
@ -1467,7 +1467,7 @@ gethostinfo(register char *hostname)
Fprintf(stderr, "%s: bad host %s\n", prog, hostname);
exit(1);
}
hi->name = savestr(hp->h_name);
hi->name = strdup(hp->h_name);
for (n = 0, p = hp->h_addr_list; *p != NULL; ++n, ++p)
continue;
hi->n = n;