From: Marco van Wieringen Date: Tue, 26 Jun 2012 19:43:19 +0000 (+0200) Subject: Fix inet_pton call. X-Git-Tag: Release-7.0.0~165 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=503e404ac07cd4adc050672b8abc1bdd073487a2;p=bacula%2Fbacula Fix inet_pton call. inet_pton returns 1 when it succeeds so the test was wrong. When it fails its either returns 0 if not a correct ipv6 address or -1 when the protocol family is not known. Checked the man page for both Linux and Solaris and this seems like an oversight as the definition is the same on these OSes and probably on all others as these functions tend to be rather portable. Also did some small rewrite of the code so its easier to read and the braces are easier to interpret. --- diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index a2b18370b3..b6775230e0 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -576,16 +576,14 @@ dlist *bnet_host2ipaddrs(const char *host, int family, const char **errstr) addr->set_type(IPADDR::R_MULTIPLE); addr->set_addr4(&inaddr); addr_list->append(addr); - } else #ifdef HAVE_IPV6 - if (inet_pton(AF_INET6, host, &inaddr6) > 1) { + } else if (inet_pton(AF_INET6, host, &inaddr6) == 1) { addr = New(IPADDR(AF_INET6)); addr->set_type(IPADDR::R_MULTIPLE); addr->set_addr6(&inaddr6); addr_list->append(addr); - } else #endif - { + } else { if (family != 0) { errmsg = resolv_host(family, host, addr_list); if (errmsg) {