Blame SOURCES/0007-xtables-translate-Guard-strcpy-call-in-xlate_ifname.patch

6ef253
From 5fe54ca701a38e283faf840903e9ed20eba8a6f4 Mon Sep 17 00:00:00 2001
6ef253
From: Phil Sutter <phil@nwl.cc>
6ef253
Date: Thu, 5 Dec 2019 16:01:29 +0100
6ef253
Subject: [PATCH] xtables-translate: Guard strcpy() call in xlate_ifname()
6ef253
6ef253
The function potentially fed overlong strings to strcpy(). Given that
6ef253
everything needed to avoid this is there, reorder code a bit to prevent
6ef253
those inputs, too.
6ef253
6ef253
Fixes: 0ddd663e9c167 ("iptables-translate: add in/out ifname wildcard match translation to nft")
6ef253
(cherry picked from commit 2861bdbbf062071487a49103513d129ce40e2652)
6ef253
Signed-off-by: Phil Sutter <psutter@redhat.com>
6ef253
---
6ef253
 iptables/xtables-translate.c | 5 ++---
6ef253
 1 file changed, 2 insertions(+), 3 deletions(-)
6ef253
6ef253
diff --git a/iptables/xtables-translate.c b/iptables/xtables-translate.c
6ef253
index a42c60a3b64c6..77a186b905d73 100644
6ef253
--- a/iptables/xtables-translate.c
6ef253
+++ b/iptables/xtables-translate.c
6ef253
@@ -32,14 +32,13 @@
6ef253
 void xlate_ifname(struct xt_xlate *xl, const char *nftmeta, const char *ifname,
6ef253
 		  bool invert)
6ef253
 {
6ef253
+	int ifaclen = strlen(ifname);
6ef253
 	char iface[IFNAMSIZ];
6ef253
-	int ifaclen;
6ef253
 
6ef253
-	if (ifname[0] == '\0')
6ef253
+	if (ifaclen < 1 || ifaclen >= IFNAMSIZ)
6ef253
 		return;
6ef253
 
6ef253
 	strcpy(iface, ifname);
6ef253
-	ifaclen = strlen(iface);
6ef253
 	if (iface[ifaclen - 1] == '+')
6ef253
 		iface[ifaclen - 1] = '*';
6ef253
 
6ef253
-- 
6ef253
2.24.0
6ef253