Index: sbin/ping6/ping6.c =================================================================== --- sbin/ping6/ping6.c +++ sbin/ping6/ping6.c @@ -661,25 +661,26 @@ } /* set the gateway (next hop) if specified */ if (gateway) { + struct addrinfo *gres; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET6; hints.ai_socktype = SOCK_RAW; hints.ai_protocol = IPPROTO_ICMPV6; - error = getaddrinfo(gateway, NULL, &hints, &res); + error = getaddrinfo(gateway, NULL, &hints, &gres); if (error) { errx(1, "getaddrinfo for the gateway %s: %s", gateway, gai_strerror(error)); } - if (res->ai_next && (options & F_VERBOSE)) + if (gres->ai_next && (options & F_VERBOSE)) warnx("gateway resolves to multiple addresses"); if (setsockopt(s, IPPROTO_IPV6, IPV6_NEXTHOP, - res->ai_addr, res->ai_addrlen)) { + gres->ai_addr, gres->ai_addrlen)) { err(1, "setsockopt(IPV6_NEXTHOP)"); } - freeaddrinfo(res); + freeaddrinfo(gres); } /* @@ -921,16 +922,17 @@ #endif /* USE_RFC2292BIS */ for (hops = 0; hops < argc - 1; hops++) { + struct addrinfo *iaip; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET6; if ((error = getaddrinfo(argv[hops], NULL, &hints, - &res))) + &iaip))) errx(1, "%s", gai_strerror(error)); - if (res->ai_addr->sa_family != AF_INET6) + if (iaip->ai_addr->sa_family != AF_INET6) errx(1, "bad addr family of an intermediate addr"); - sin6 = (struct sockaddr_in6 *)(void *)res->ai_addr; + sin6 = (struct sockaddr_in6 *)(void *)iaip->ai_addr; #ifdef USE_RFC2292BIS if (inet6_rth_add(rthdr, &sin6->sin6_addr)) errx(1, "can't add an intermediate node"); @@ -939,7 +941,7 @@ IPV6_RTHDR_LOOSE)) errx(1, "can't add an intermediate node"); #endif /* USE_RFC2292BIS */ - freeaddrinfo(res); + freeaddrinfo(iaip); } #ifndef USE_RFC2292BIS