From 136d56f7b3c58e753661f0e064e17e91e87b520a Mon Sep 17 00:00:00 2001 From: deraadt Date: Thu, 8 Oct 2015 13:55:56 +0000 Subject: [PATCH] Handle case where no hint is passed in. Found as a crash of fdm by jturner@ --- lib/libc/asr/getaddrinfo.c | 4 ++-- lib/libc/asr/getaddrinfo_async.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libc/asr/getaddrinfo.c b/lib/libc/asr/getaddrinfo.c index e932e46b948..b6ce8a9d64d 100644 --- a/lib/libc/asr/getaddrinfo.c +++ b/lib/libc/asr/getaddrinfo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getaddrinfo.c,v 1.7 2015/10/07 13:57:12 deraadt Exp $ */ +/* $OpenBSD: getaddrinfo.c,v 1.8 2015/10/08 13:55:56 deraadt Exp $ */ /* * Copyright (c) 2012 Eric Faurot * @@ -32,7 +32,7 @@ getaddrinfo(const char *hostname, const char *servname, struct asr_result ar; int saved_errno = errno; - if ((hints->ai_flags & AI_NUMERICHOST) == 0) + if (hints && (hints->ai_flags & AI_NUMERICHOST) == 0) res_init(); as = getaddrinfo_async(hostname, servname, hints, NULL); diff --git a/lib/libc/asr/getaddrinfo_async.c b/lib/libc/asr/getaddrinfo_async.c index 4362da51514..0a411adac63 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.46 2015/10/07 13:59:34 deraadt Exp $ */ +/* $OpenBSD: getaddrinfo_async.c,v 1.47 2015/10/08 13:55:56 deraadt Exp $ */ /* * Copyright (c) 2012 Eric Faurot * @@ -88,7 +88,7 @@ getaddrinfo_async(const char *hostname, const char *servname, struct asr_query *as; char alias[MAXDNAME]; - if ((hints->ai_flags & AI_NUMERICHOST) == 0) + if (hints && (hints->ai_flags & AI_NUMERICHOST) == 0) ac = _asr_use_resolver(asr); else ac = _asr_no_resolver(); -- 2.20.1