From 656b8d513650c05e27d8c5044c6432310062d847 Mon Sep 17 00:00:00 2001 From: deraadt Date: Wed, 7 Oct 2015 13:59:34 +0000 Subject: [PATCH] getaddrinfo_async() shouldn't unconditionally intialize the resolver via _asr_use_resolver(). If the hint specifies for AI_NUMERICHOST, create a transient lookup context which won't try to open /etc/reslov.conf ok eric guenther --- lib/libc/asr/asr.c | 8 +++++++- lib/libc/asr/asr_private.h | 3 ++- lib/libc/asr/getaddrinfo_async.c | 7 +++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/libc/asr/asr.c b/lib/libc/asr/asr.c index 1f6429f5109..7c13122a8cb 100644 --- a/lib/libc/asr/asr.c +++ b/lib/libc/asr/asr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asr.c,v 1.45 2015/10/03 22:35:30 deraadt Exp $ */ +/* $OpenBSD: asr.c,v 1.46 2015/10/07 13:59:34 deraadt Exp $ */ /* * Copyright (c) 2010-2012 Eric Faurot * @@ -489,6 +489,12 @@ asr_ctx_create(void) return (ac); } +struct asr_ctx * +_asr_no_resolver(void) +{ + return asr_ctx_create(); +} + /* * Add a search domain to the async context. */ diff --git a/lib/libc/asr/asr_private.h b/lib/libc/asr/asr_private.h index 82ad6dc46d7..cef9cae373e 100644 --- a/lib/libc/asr/asr_private.h +++ b/lib/libc/asr/asr_private.h @@ -1,4 +1,4 @@ -/* $OpenBSD: asr_private.h,v 1.34 2015/10/03 22:35:30 deraadt Exp $ */ +/* $OpenBSD: asr_private.h,v 1.35 2015/10/07 13:59:34 deraadt Exp $ */ /* * Copyright (c) 2012 Eric Faurot * @@ -315,6 +315,7 @@ ssize_t _asr_addr_as_fqdn(const char *, int, char *, size_t); static void *_asr_resolver(void); void _asr_resolver_done(void *); struct asr_ctx *_asr_use_resolver(void *); +struct asr_ctx *_asr_no_resolver(void); void _asr_ctx_unref(struct asr_ctx *); struct asr_query *_asr_async_new(struct asr_ctx *, int); void _asr_async_free(struct asr_query *); diff --git a/lib/libc/asr/getaddrinfo_async.c b/lib/libc/asr/getaddrinfo_async.c index d3e7c569d14..4362da51514 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.45 2015/09/20 14:19:21 eric Exp $ */ +/* $OpenBSD: getaddrinfo_async.c,v 1.46 2015/10/07 13:59:34 deraadt Exp $ */ /* * Copyright (c) 2012 Eric Faurot * @@ -88,7 +88,10 @@ getaddrinfo_async(const char *hostname, const char *servname, struct asr_query *as; char alias[MAXDNAME]; - ac = _asr_use_resolver(asr); + if ((hints->ai_flags & AI_NUMERICHOST) == 0) + ac = _asr_use_resolver(asr); + else + ac = _asr_no_resolver(); if ((as = _asr_async_new(ac, ASR_GETADDRINFO)) == NULL) goto abort; /* errno set */ as->as_run = getaddrinfo_async_run; -- 2.20.1