summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2021-03-24 14:45:02 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-03-24 18:14:45 +0100
commitd2f4a9488ce0847da754614706fadefbca9ed2a4 (patch)
tree9e3d7ca656c62ac28632813b3f7fc69a7bd7eb72
parent91a96a564f5fc0dbad15f1c23a0fbda157a03558 (diff)
downloadsystemd-d2f4a9488ce0847da754614706fadefbca9ed2a4.tar.gz
systemd-d2f4a9488ce0847da754614706fadefbca9ed2a4.tar.bz2
systemd-d2f4a9488ce0847da754614706fadefbca9ed2a4.zip
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)
-rw-r--r--src/shared/local-addresses.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/shared/local-addresses.c b/src/shared/local-addresses.c
index 2c860f76d5..1de890f142 100644
--- a/src/shared/local-addresses.c
+++ b/src/shared/local-addresses.c
@@ -204,7 +204,7 @@ int local_gateways(sd_netlink *context, int ifindex, int af, struct local_addres
union in_addr_union gateway;
uint16_t type;
unsigned char dst_len, src_len, table;
- uint32_t ifi, metric = 0;
+ uint32_t ifi = 0, metric = 0;
size_t rta_len;
int family;
RouteVia via;