diff --git a/dns.c b/dns.c index e2db851..2d53481 100644 --- a/dns.c +++ b/dns.c @@ -452,15 +452,22 @@ match_ipv6_addresses(char *reverse_ip, struct in6_addr *intf_ip) continue; if (j == 4) { + if (idx == sizeof temp_ip - 1) + break; temp_ip[idx] = ':'; idx++; j = 0; } + + if (idx == sizeof temp_ip - 1) + break; temp_ip[idx] = reverse_ip[i]; idx++; j++; } + temp_ip[idx] = '\0'; + if (inet_pton(AF_INET6, temp_ip, &buf) <= 0) return 0;