From: florian Date: Tue, 21 Nov 2023 15:26:56 +0000 (+0000) Subject: Do not short-circuit localhost resolution when AI_NUMERICHOST is set. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=fada2b0bd226843a6444c75947c346f81ce1fa83;p=openbsd Do not short-circuit localhost resolution when AI_NUMERICHOST is set. localhost is not a valid IP address and so getaddrinfo(3) has to fail. Found by anton in pfctl & ipsecctl regress. OK anton --- diff --git a/lib/libc/asr/getaddrinfo_async.c b/lib/libc/asr/getaddrinfo_async.c index d5a9561faf2..a1282e711cd 100644 --- a/lib/libc/asr/getaddrinfo_async.c +++ b/lib/libc/asr/getaddrinfo_async.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getaddrinfo_async.c,v 1.60 2023/11/20 12:15:16 florian Exp $ */ +/* $OpenBSD: getaddrinfo_async.c,v 1.61 2023/11/21 15:26:56 florian Exp $ */ /* * Copyright (c) 2012 Eric Faurot * @@ -115,7 +115,7 @@ getaddrinfo_async_run(struct asr_query *as, struct asr_result *ar) char fqdn[MAXDNAME]; const char *str; struct addrinfo *ai; - int i, family, r, is_localhost; + int i, family, r, is_localhost = 0; FILE *f; union { struct sockaddr sa; @@ -228,7 +228,8 @@ getaddrinfo_async_run(struct asr_query *as, struct asr_result *ar) ar->ar_gai_errno = 0; - is_localhost = _asr_is_localhost(as->as.ai.hostname); + if (!(ai->ai_flags & AI_NUMERICHOST)) + is_localhost = _asr_is_localhost(as->as.ai.hostname); /* * If hostname is NULL, "localhost" or falls within the * ".localhost." domain, use local address.