From e57fd51a5e23b637f9c178a59eb9fb42861bd83f Mon Sep 17 00:00:00 2001 From: Martin Bark Date: Mon, 14 Dec 2015 21:36:21 +0000 Subject: [PATCH] os: fix crash in GetInterfaceAddresses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If uv_interface_addresses() returns UV_ENOSYS then interfaces and count are uninitialised. This can cause a segmentation fault inside GetInterfaceAddresses when it tries to use the invalid interfaces[]. Fix the issue by returning from GetInterfaceAddresses on the UV_ENOSYS error. This issue was observed when using uCLibc-ng version 1.0.9 because uv_interface_addresses() in deps/uv/src/unix/linux-core.c incorrectly undefines HAVE_IFADDRS_H. Signed-off-by: Martin Bark PR-URL: https://github.com/nodejs/node/pull/4272 Reviewed-By: Colin Ihrig Reviewed-By: Brian White Reviewed-By: Saúl Ibarra Corretgé Reviewed-By: James M Snell Reviewed-By: Rod Vagg --- src/node_os.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_os.cc b/src/node_os.cc index a1000907485519..92f53a9c407fae 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -200,7 +200,7 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo& args) { ret = Object::New(env->isolate()); if (err == UV_ENOSYS) { - args.GetReturnValue().Set(ret); + return args.GetReturnValue().Set(ret); } else if (err) { return env->ThrowUVException(err, "uv_interface_addresses"); }