From 8bad51977ae63e21a5975e6f4a5b908afd5c5cc6 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 15 Jan 2016 16:54:13 -0500 Subject: [PATCH] src: return UV_EAI_NODATA on empty lookup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AfterGetAddrInfo() can potentially return an empty array of results without setting an error value. The JavaScript layer expects the array to have at least one value if an error is not returned. This commit sets a UV_EAI_NODATA error when an empty result array is detected. Fixes: https://github.com/nodejs/node/issues/4545 PR-URL: https://github.com/nodejs/node/pull/4715 Reviewed-By: Ben Noordhuis Reviewed-By: Evan Lucas Reviewed-By: Saúl Ibarra Corretgé --- src/cares_wrap.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index 8f57dfe477cda4..46636c528b7f81 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -983,6 +983,10 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) { address = address->ai_next; } + // No responses were found to return + if (n == 0) { + argv[0] = Integer::New(env->isolate(), UV_EAI_NODATA); + } argv[1] = results; }