getifaddrs: fix UB via taking address of null pointer union dereference
authorAlexey Izbyshev <izbyshev@ispras.ru>
Mon, 27 Feb 2023 20:05:16 +0000 (23:05 +0300)
committerRich Felker <dalias@aerifal.cx>
Tue, 28 Feb 2023 16:59:53 +0000 (11:59 -0500)
commit1a708ece1ad8b924466e81c5fcdf4e22311fd770
tree55419af5ea43de87affd4f0001fe49b92b600eb7
parentc499c1084eaccd83e4b6e60883a5d92df0202c5e
getifaddrs: fix UB via taking address of null pointer union dereference

getifaddrs computes &ctx->first->ifa even if ctx->first is NULL. While
this shouldn't be possible on the success path because the loopback
interface is hardcoded into the kernel, this is still possible on the
error path (for example, if __rtnetlink_enumerate couldn't create a
socket due to exceeding the fd limit).
src/network/getifaddrs.c