From 369cc50768a9929ef0adf4b58987ce08cc3675b6 Mon Sep 17 00:00:00 2001 From: Olaf Kirch Date: Tue, 20 Aug 2013 09:12:49 +0200 Subject: [PATCH 05/13] The use of AI_NUMERICHOST in init_transport() is broken. In its current form, when seeing a dotted quad or a numeric IPv6 address, it will clear all flags in hints.ai_flags (which has been set to AI_PASSIVE a few lines above). What this code should really be doing is to *set* AI_NUMERICHOST if and only if it sees a numeric address. Signed-off-by: Olaf Kirch --- src/rpcbind.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rpcbind.c b/src/rpcbind.c index f562f7a..896d509 100644 --- a/src/rpcbind.c +++ b/src/rpcbind.c @@ -365,11 +365,13 @@ init_transport(struct netconfig *nconf) nconf->nc_netid); return (1); } + + hints.ai_flags &= ~AI_NUMERICHOST; switch (hints.ai_family) { case AF_INET: if (inet_pton(AF_INET, hosts[nhostsbak], host_addr) == 1) { - hints.ai_flags &= AI_NUMERICHOST; + hints.ai_flags |= AI_NUMERICHOST; } else { /* * Skip if we have an AF_INET6 adress. @@ -382,7 +384,7 @@ init_transport(struct netconfig *nconf) case AF_INET6: if (inet_pton(AF_INET6, hosts[nhostsbak], host_addr) == 1) { - hints.ai_flags &= AI_NUMERICHOST; + hints.ai_flags |= AI_NUMERICHOST; } else { /* * Skip if we have an AF_INET adress. -- 1.7.12.4