From 065d891402bc37d50378825ad81dfecfd6fbbea2 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 15 May 2019 21:00:52 +0200 Subject: [PATCH] platform: use memset() to initialize ifr struct in _ioctl_call() "struct ifreq" contains a union field, and initalizing the struct is not guaranteed to fill all bytes with zero (it only sets the first union member to zero). Since we later return the entire struct, ensure that it's initialized to all zero by using memset(). --- src/platform/nm-platform-utils.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c index 4eaea41bc5..df0efa270d 100644 --- a/src/platform/nm-platform-utils.c +++ b/src/platform/nm-platform-utils.c @@ -173,9 +173,7 @@ again: nm_assert (ifname && nm_utils_is_valid_iface_name (ifname, NULL)); nm_assert (fd >= 0); - ifr = (struct ifreq) { - .ifr_data = NULL, - }; + memset (&ifr, 0, sizeof (ifr)); memcpy (ifr.ifr_name, ifname, IFNAMSIZ); if (edata_type == IOCTL_CALL_DATA_TYPE_IFRDATA) ifr.ifr_data = edata;