Blob Blame History Raw
From 7fd4eb9313154f3b3458ea07d6a12f0be26d2a4e Mon Sep 17 00:00:00 2001
From: Lee Duncan <lduncan@suse.com>
Date: Wed, 21 Mar 2018 16:43:33 -0700
Subject: [PATCH] Use correct size when copying nic name.

The incorrect length was being used to copy
the NIC name.

Found by gcc-8, which gave this error:
>    [   19s] nic_utils.c: In function 'nic_util_enable_disable_multicast':
>    [   19s] nic_utils.c:308:9: warning: argument to 'sizeof' in 'strncpy'
>             call is the same expression as the source; did you mean to
>             use the size of the destination? [-Wsizeof-pointer-memaccess]
>    [   19s]    sizeof(nic->eth_device_name));
>    [   19s]          ^
---
 iscsiuio/src/unix/nic_utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/iscsiuio/src/unix/nic_utils.c b/iscsiuio/src/unix/nic_utils.c
index e2f294389840..786f2a4d5b5d 100644
--- a/iscsiuio/src/unix/nic_utils.c
+++ b/iscsiuio/src/unix/nic_utils.c
@@ -305,7 +305,7 @@ static int nic_util_enable_disable_multicast(nic_t *nic, uint32_t cmd)
 	/* Prepare the request */
 	memset(&ifr, 0, sizeof(ifr));
 	strncpy(ifr.ifr_name, nic->eth_device_name,
-		sizeof(nic->eth_device_name));
+		sizeof(ifr.ifr_name));
 	memcpy(ifr.ifr_hwaddr.sa_data, multicast_addr.addr, ETH_ALEN);
 
 	fd = socket(AF_INET, SOCK_DGRAM, 0);
-- 
2.17.2