From b13d71d5a2adc794bc413e4ef326d9a864019dd7 Mon Sep 17 00:00:00 2001 From: pdw <> Date: Wed, 1 Jan 2014 12:01:57 +0000 Subject: [PATCH] Patch by Robert Scheck for iftop <= 1.0pre2 to avoid an assertion failure if an "invalid" (as in outside of IPv4 or IPv6) address family is passed to nss-myhostname's gethostbyaddr_r(). For further information please have a look to Red Hat Bugzilla IDs #839750, #847124, #868065, #961236 and #1007434: - https://bugzilla.redhat.com/show_bug.cgi?id=839750 - https://bugzilla.redhat.com/show_bug.cgi?id=847124 - https://bugzilla.redhat.com/show_bug.cgi?id=868065 - https://bugzilla.redhat.com/show_bug.cgi?id=961236 - https://bugzilla.redhat.com/show_bug.cgi?id=1007434 --- resolver.c | 5 +++++ 1 file changed, 5 insertions(+) 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) {