Blame SOURCES/0003-fix-VLAN-device-name-overflow-check.patch

bf9e84
From b9885692cb283a674e04528486984fb61f92a190 Mon Sep 17 00:00:00 2001
bf9e84
From: Chris Leech <cleech@redhat.com>
bf9e84
Date: Tue, 23 Mar 2021 11:21:17 -0700
bf9e84
Subject: [PATCH 3/5] fix VLAN device name overflow check
bf9e84
bf9e84
check snprintf return for truncation
bf9e84
bf9e84
Signed-off-by: Chris Leech <cleech@redhat.com>
bf9e84
---
bf9e84
 fipvlan.c | 12 ++++++++++--
bf9e84
 1 file changed, 10 insertions(+), 2 deletions(-)
bf9e84
bf9e84
diff --git a/fipvlan.c b/fipvlan.c
bf9e84
index fe8d7955cc5..3ce913d5eaf 100644
bf9e84
--- a/fipvlan.c
bf9e84
+++ b/fipvlan.c
bf9e84
@@ -624,8 +624,16 @@ create_and_start_vlan(struct fcf *fcf, bool vn2vn)
bf9e84
 				    real_dev->ifname, fcf->vlan, vlan->ifname);
bf9e84
 			rc = 0;
bf9e84
 		} else {
bf9e84
-			snprintf(vlan_name, IFNAMSIZ, "%s.%d%s",
bf9e84
-				 real_dev->ifname, fcf->vlan, config.suffix);
bf9e84
+			rc = snprintf(vlan_name, IFNAMSIZ, "%s.%d%s",
bf9e84
+					real_dev->ifname, fcf->vlan,
bf9e84
+					config.suffix);
bf9e84
+			if (rc < 0 || rc >= IFNAMSIZ) {
bf9e84
+				printf("Failed to create VLAN device "
bf9e84
+					"(name %s.%d%s is too long)\n",
bf9e84
+					real_dev->ifname, fcf->vlan,
bf9e84
+					config.suffix);
bf9e84
+				return -EINVAL;
bf9e84
+			}
bf9e84
 			rc = vlan_create(fcf->ifindex, fcf->vlan, vlan_name);
bf9e84
 			if (rc < 0)
bf9e84
 				printf("Failed to create VLAN device %s\n\t%s\n",
bf9e84
-- 
bf9e84
2.26.2
bf9e84