From: Roy Marples Date: Sat, 23 Feb 2008 23:12:54 +0000 (+0000) Subject: Fix hostname lookup, #31 X-Git-Tag: v3.2.3~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57a0827f7090929a3b2ef6a5d4b95f67ea8593c8;p=thirdparty%2Fdhcpcd.git Fix hostname lookup, #31 --- diff --git a/configure.c b/configure.c index 131f771a..2c42282a 100644 --- a/configure.c +++ b/configure.c @@ -452,7 +452,7 @@ static char *lookuphostname (char *hostname, const dhcp_t *dhcp, socklen_t salen; char *addr; struct addrinfo hints; - struct addrinfo *res; + struct addrinfo *res = NULL; int result; char *p; @@ -477,7 +477,8 @@ static char *lookuphostname (char *hostname, const dhcp_t *dhcp, hints.ai_socktype = SOCK_DGRAM; hints.ai_flags = AI_NUMERICHOST; result = getaddrinfo (addr, "0", &hints, &res); - freeaddrinfo (res); + if (res) + freeaddrinfo (res); if (result == 0) logger (LOG_ERR, "malicious PTR record detected"); if (result == 0 || ! *addr) { @@ -774,7 +775,7 @@ int configure (const options_t *options, interface_t *iface, /* Now we have made a resolv.conf we can obtain a hostname * if we need it */ - if (! *newhostname && options->dohostname > 3) + if (! *newhostname || options->dohostname > 3) lookuphostname (newhostname, dhcp, options); if (*newhostname) {