diff options
author | araujo <araujo@FreeBSD.org> | 2016-07-05 07:01:42 +0000 |
---|---|---|
committer | araujo <araujo@FreeBSD.org> | 2016-07-05 07:01:42 +0000 |
commit | 448dc2b255257036cf847eaba84b9ec97c8225aa (patch) | |
tree | 9b2ac3dbfff43f59d3efa360bde9cbdf1054a690 | |
parent | d88fefb346f119b5e45912dab7051d8450a791d3 (diff) | |
download | FreeBSD-src-448dc2b255257036cf847eaba84b9ec97c8225aa.zip FreeBSD-src-448dc2b255257036cf847eaba84b9ec97c8225aa.tar.gz |
Fix a regression introduced on revision r271909, when using argument -g
or several hops we have segmentation fault because we overwrite the same
structure to store information for host and gateway.
Submitted by: Maryse Levavasseur <maryse.levavasseur@stormshield.eu>
Reworked by: hrs
Approved by: re (hrs)
Differential Revision: https://reviews.freebsd.org/D6980
-rw-r--r-- | sbin/ping6/ping6.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index 732e634..51a154d 100644 --- a/sbin/ping6/ping6.c +++ b/sbin/ping6/ping6.c @@ -515,7 +515,6 @@ main(int argc, char *argv[]) memcpy(&src, res->ai_addr, res->ai_addrlen); srclen = res->ai_addrlen; freeaddrinfo(res); - res = NULL; options |= F_SRCADDR; break; case 's': /* size of packet to send */ @@ -631,7 +630,7 @@ main(int argc, char *argv[]) if (error) errx(1, "%s", gai_strerror(error)); if (res->ai_canonname) - hostname = res->ai_canonname; + hostname = strdup(res->ai_canonname); else hostname = target; @@ -643,6 +642,7 @@ main(int argc, char *argv[]) if ((s = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) err(1, "socket"); + freeaddrinfo(res); /* set the source address if specified. */ if ((options & F_SRCADDR) != 0) { @@ -1208,9 +1208,6 @@ main(int argc, char *argv[]) sigaction(SIGALRM, &si_sa, 0); summary(); - if (res != NULL) - freeaddrinfo(res); - if(packet != NULL) free(packet); |