diff --git a/resolver.c b/resolver.c index 3ca8835..b42e544 100644 --- a/resolver.c +++ b/resolver.c @@ -117,6 +117,10 @@ char* do_resolve(struct addr_storage *addr) { /* Allocate buffer, remember to free it to avoid memory leakage. */ tmphstbuf = xmalloc (hstbuflen); + /* nss-myhostname's gethostbyaddr_r() causes an assertion failure if an + * "invalid" (as in outside of IPv4 or IPv6) address family is passed */ + if (addr->af == AF_INET || addr->af == AF_INET6) { + /* Some machines have gethostbyaddr_r returning an integer error code; on * others, it returns a struct hostent*. */ #ifdef GETHOSTBYADDR_R_RETURNS_INT @@ -135,6 +139,7 @@ char* do_resolve(struct addr_storage *addr) { hstbuflen *= 2; tmphstbuf = realloc (tmphstbuf, hstbuflen); } + } /* Check for errors. */ if (res || hp == NULL) {