From: David Schweikert Date: Fri, 21 Oct 2022 13:34:37 +0000 (+0200) Subject: correctly call getnameinfo() X-Git-Url: https://git.gsnw.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8dc0b7f39a09f0745ba308292c3ac1c6013394c3;p=fping.git correctly call getnameinfo() --- diff --git a/src/fping.c b/src/fping.c index a8e43ab..9bda407 100644 --- a/src/fping.c +++ b/src/fping.c @@ -2134,7 +2134,7 @@ int decode_icmp_ipv4( return -1; } - getnameinfo(response_addr, sizeof(struct sockaddr_in), addr_ascii, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST); + getnameinfo(response_addr, response_addr_len, addr_ascii, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST); switch (icp->icmp_type) { case ICMP_UNREACH: @@ -2193,7 +2193,7 @@ int decode_icmp_ipv6( if (reply_buf_len < sizeof(struct icmp6_hdr)) { if (verbose_flag) { char buf[INET6_ADDRSTRLEN]; - getnameinfo((struct sockaddr *)&response_addr, sizeof(response_addr), buf, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST); + getnameinfo(response_addr, response_addr_len, buf, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST); printf("received packet too short for ICMP (%d bytes from %s)\n", (int)reply_buf_len, buf); } return 0; /* too short */