On Jan 18, Michael Meskes <[email protected]> wrote: > Could you please debug hostname? It printfs buf in line 317 which is set by > calling getnameinfo in line 310. Does getnameinfo really return this > character? > Or is an error return not correctly caught? Indeed, you are not supposed to use the buffer if getnameinfo(2) fails (because I have an interface with no rDNS). Patch attached.
-- ciao, Marco
--- a/hostname.c 2010-01-15 13:12:12.000000000 +0100
+++ b/hostname.c 2010-01-19 01:48:05.337523465 +0100
@@ -311,10 +311,11 @@
buf, sizeof(buf), NULL, 0, flags);
/* Just skip addresses that cannot be translated */
- if (ret != 0 && (type != ALL_FQDNS || ret != EAI_NONAME))
+ if (ret != 0) {
+ if (type != ALL_FQDNS && ret != EAI_NONAME)
errx(1, "%s", gai_strerror(ret));
-
- printf("%s ", buf);
+ } else
+ printf("%s ", buf);
}
printf("\n");
freeifaddrs(ifa);
signature.asc
Description: Digital signature

