os: fix crash in GetInterfaceAddresses
authorMartin Bark <martin@barkynet.com>
Mon, 14 Dec 2015 21:36:21 +0000 (21:36 +0000)
committerMyles Borins <mborins@us.ibm.com>
Tue, 19 Jan 2016 19:52:32 +0000 (11:52 -0800)
commit8ce6843fe4fbe844a9a879d37321a3cda8e256ed
tree5ac785766ed84b2217209c86b8a71e6f2de75df2
parentf613b3033fd3798c0b58b1cff0eb1b5c7542bf0f
os: fix crash in GetInterfaceAddresses

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 <martin@barkynet.com>
PR-URL: https://github.com/nodejs/node/pull/4272
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
src/node_os.cc