Blame SOURCES/0009-nft-Avoid-buffer-size-warnings-copying-iface-names.patch

3a00e5
From dda5f0d0ebbcb39f4e001335f70159121f554886 Mon Sep 17 00:00:00 2001
3a00e5
From: Phil Sutter <phil@nwl.cc>
3a00e5
Date: Wed, 2 Jun 2021 11:58:06 +0200
3a00e5
Subject: [PATCH] nft: Avoid buffer size warnings copying iface names
3a00e5
3a00e5
The call to strncpy() is actually not needed: source buffer is only
3a00e5
IFNAMSIZ bytes large and guaranteed to be null-terminated. Use this to
3a00e5
avoid compiler warnings due to size parameter matching the destination
3a00e5
buffer size by performing the copy using (dumb) memcpy() instead.
3a00e5
3a00e5
Signed-off-by: Phil Sutter <phil@nwl.cc>
3a00e5
(cherry picked from commit 0729ab37c5d90b78dd3bc8c9addb8a1c60708eff)
3a00e5
---
3a00e5
 iptables/nft-ipv4.c | 4 ++--
3a00e5
 iptables/nft-ipv6.c | 4 ++--
3a00e5
 2 files changed, 4 insertions(+), 4 deletions(-)
3a00e5
3a00e5
diff --git a/iptables/nft-ipv4.c b/iptables/nft-ipv4.c
3a00e5
index a5b835b1f681d..34f94bd8cc24a 100644
3a00e5
--- a/iptables/nft-ipv4.c
3a00e5
+++ b/iptables/nft-ipv4.c
3a00e5
@@ -348,11 +348,11 @@ static void nft_ipv4_post_parse(int command,
3a00e5
 	 */
3a00e5
 	cs->fw.ip.invflags = args->invflags;
3a00e5
 
3a00e5
-	strncpy(cs->fw.ip.iniface, args->iniface, IFNAMSIZ);
3a00e5
+	memcpy(cs->fw.ip.iniface, args->iniface, IFNAMSIZ);
3a00e5
 	memcpy(cs->fw.ip.iniface_mask,
3a00e5
 	       args->iniface_mask, IFNAMSIZ*sizeof(unsigned char));
3a00e5
 
3a00e5
-	strncpy(cs->fw.ip.outiface, args->outiface, IFNAMSIZ);
3a00e5
+	memcpy(cs->fw.ip.outiface, args->outiface, IFNAMSIZ);
3a00e5
 	memcpy(cs->fw.ip.outiface_mask,
3a00e5
 	       args->outiface_mask, IFNAMSIZ*sizeof(unsigned char));
3a00e5
 
3a00e5
diff --git a/iptables/nft-ipv6.c b/iptables/nft-ipv6.c
3a00e5
index 46008fc5e762a..d9c9400ad7dc3 100644
3a00e5
--- a/iptables/nft-ipv6.c
3a00e5
+++ b/iptables/nft-ipv6.c
3a00e5
@@ -293,11 +293,11 @@ static void nft_ipv6_post_parse(int command, struct iptables_command_state *cs,
3a00e5
 	 */
3a00e5
 	cs->fw6.ipv6.invflags = args->invflags;
3a00e5
 
3a00e5
-	strncpy(cs->fw6.ipv6.iniface, args->iniface, IFNAMSIZ);
3a00e5
+	memcpy(cs->fw6.ipv6.iniface, args->iniface, IFNAMSIZ);
3a00e5
 	memcpy(cs->fw6.ipv6.iniface_mask,
3a00e5
 	       args->iniface_mask, IFNAMSIZ*sizeof(unsigned char));
3a00e5
 
3a00e5
-	strncpy(cs->fw6.ipv6.outiface, args->outiface, IFNAMSIZ);
3a00e5
+	memcpy(cs->fw6.ipv6.outiface, args->outiface, IFNAMSIZ);
3a00e5
 	memcpy(cs->fw6.ipv6.outiface_mask,
3a00e5
 	       args->outiface_mask, IFNAMSIZ*sizeof(unsigned char));
3a00e5
 
3a00e5
-- 
3a00e5
2.31.1
3a00e5