]> git.ipfire.org Git - thirdparty/systemd.git/commit
local-addresses: fix use of uninitialized value
authorDavid Tardon <dtardon@redhat.com>
Wed, 24 Mar 2021 13:45:02 +0000 (14:45 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 24 Mar 2021 17:14:45 +0000 (18:14 +0100)
commitd2f4a9488ce0847da754614706fadefbca9ed2a4
tree9e3d7ca656c62ac28632813b3f7fc69a7bd7eb72
parent91a96a564f5fc0dbad15f1c23a0fbda157a03558
local-addresses: fix use of uninitialized value

This can happen if ifi fails to be read from the netlink message and the
error is ENODATA.

Fixes the following valgrind message when running netstat:

==164141== Conditional jump or move depends on uninitialised value(s)
==164141==    at 0x524AE60: address_compare (local-addresses.c:29)
==164141==    by 0x48BCC78: msort_with_tmp.part.0 (msort.c:105)
==164141==    by 0x48BC9E4: msort_with_tmp (msort.c:45)
==164141==    by 0x48BC9E4: msort_with_tmp.part.0 (msort.c:53)
==164141==    by 0x48BCF85: msort_with_tmp (msort.c:45)
==164141==    by 0x48BCF85: qsort_r (msort.c:297)
==164141==    by 0x52500FC: UnknownInlinedFun (sort-util.h:47)
==164141==    by 0x52500FC: local_gateways.constprop.0 (local-addresses.c:310)
==164141==    by 0x5251C05: _nss_myhostname_gethostbyaddr2_r (nss-myhostname.c:456)
==164141==    by 0x5252006: _nss_myhostname_gethostbyaddr_r (nss-myhostname.c:500)
==164141==    by 0x498E7FE: gethostbyaddr_r@@GLIBC_2.2.5 (getXXbyYY_r.c:274)
==164141==    by 0x498E560: gethostbyaddr (getXXbyYY.c:135)
==164141==    by 0x121353: INET_rresolve.constprop.0 (inet.c:212)
==164141==    by 0x1135B9: INET_sprint (inet.c:261)
==164141==    by 0x121BFC: addr_do_one.constprop.0.isra.0 (netstat.c:1156)
src/shared/local-addresses.c