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