From: florian Date: Mon, 15 Jan 2024 18:03:39 +0000 (+0000) Subject: Make sure to return a proper string in ai_canonname. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ab51fa82de9b05dfd7bcb4cefd40ef36eed0e55c;p=openbsd Make sure to return a proper string in ai_canonname. When we made sure that getaddrinfo(3) always resolves "localhost" to the loopback address we forgot to set ai_canonname if AI_CANONNAME or AI_FQDN is set. On a successful call ai_canonname has to be a NUL-terminated string if either of those flags are set. Problem observed by a@alexis-fouilhe.fr in smtpd(8) with a hostname of "localhost". OK millert --- diff --git a/lib/libc/asr/getaddrinfo_async.c b/lib/libc/asr/getaddrinfo_async.c index a1282e711cd..23262f5163f 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.61 2023/11/21 15:26:56 florian Exp $ */ +/* $OpenBSD: getaddrinfo_async.c,v 1.62 2024/01/15 18:03:39 florian Exp $ */ /* * Copyright (c) 2012 Eric Faurot * @@ -258,7 +258,8 @@ getaddrinfo_async_run(struct asr_query *as, struct asr_result *ar) !is_localhost) ? "::" : "::1"; /* This can't fail */ _asr_sockaddr_from_str(&sa.sa, family, str); - if ((r = addrinfo_add(as, &sa.sa, NULL))) { + if ((r = addrinfo_add(as, &sa.sa, + "localhost."))) { ar->ar_gai_errno = r; break; }