From 2ead0dac8a4e3fd4c81a98096ba84e9e2bd58dd7 Mon Sep 17 00:00:00 2001 From: deraadt Date: Wed, 7 Oct 2015 13:57:12 +0000 Subject: [PATCH] getaddrinfo() should not res_init() unconditionally, but allow lower layers to decide. The request could be AI_NUMERICHOST. [And the process could be tame()-constrained to not open /etc/resolv.conf] ok eric guenther --- lib/libc/asr/getaddrinfo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/libc/asr/getaddrinfo.c b/lib/libc/asr/getaddrinfo.c index d988b9ae16d..e932e46b948 100644 --- a/lib/libc/asr/getaddrinfo.c +++ b/lib/libc/asr/getaddrinfo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getaddrinfo.c,v 1.6 2015/09/14 07:38:37 guenther Exp $ */ +/* $OpenBSD: getaddrinfo.c,v 1.7 2015/10/07 13:57:12 deraadt Exp $ */ /* * Copyright (c) 2012 Eric Faurot * @@ -32,7 +32,8 @@ getaddrinfo(const char *hostname, const char *servname, struct asr_result ar; int saved_errno = errno; - res_init(); + if ((hints->ai_flags & AI_NUMERICHOST) == 0) + res_init(); as = getaddrinfo_async(hostname, servname, hints, NULL); if (as == NULL) { -- 2.20.1