From 4ccb58160936d13a06c74ed1c28c855564b50f22 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 7 May 2020 11:06:03 +0200 Subject: [PATCH] lib/socket: let query_iface_speed_from_name() initialize memory passed to syscalls I'm not sure if struct initializers would take care of padding, so I use ZERO_STRUCT(). Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme --- lib/socket/interfaces.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/socket/interfaces.c b/lib/socket/interfaces.c index ac26b97c248..497bd945984 100644 --- a/lib/socket/interfaces.c +++ b/lib/socket/interfaces.c @@ -149,6 +149,7 @@ static void query_iface_speed_from_name(const char *name, uint64_t *speed) strlcpy(ifr.ifr_name, name, IF_NAMESIZE); ifr.ifr_data = (void *)&edata; + ZERO_STRUCT(edata); edata.cmd = ETHTOOL_GLINK; ret = ioctl(fd, SIOCETHTOOL, &ifr); if (ret == -1) { @@ -161,6 +162,7 @@ static void query_iface_speed_from_name(const char *name, uint64_t *speed) } ifr.ifr_data = (void *)&ecmd; + ZERO_STRUCT(ecmd); ecmd.cmd = ETHTOOL_GSET; ret = ioctl(fd, SIOCETHTOOL, &ifr); if (ret == -1) {