加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-01-fix_VLAN_device_name_overflow_check.patch 1.13 KB
一键复制 编辑 原始数据 按行查看 历史
From b9885692cb283a674e04528486984fb61f92a190 Mon Sep 17 00:00:00 2001
From: Chris Leech <cleech@redhat.com>
Date: Tue, 23 Mar 2021 11:21:17 -0700
Subject: [PATCH] fix VLAN device name overflow check
check snprintf return for truncation
Signed-off-by: Chris Leech <cleech@redhat.com>
---
fipvlan.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/fipvlan.c b/fipvlan.c
index fe8d7955cc5..3ce913d5eaf 100644
--- a/fipvlan.c
+++ b/fipvlan.c
@@ -624,8 +624,16 @@ create_and_start_vlan(struct fcf *fcf, bool vn2vn)
real_dev->ifname, fcf->vlan, vlan->ifname);
rc = 0;
} else {
- snprintf(vlan_name, IFNAMSIZ, "%s.%d%s",
- real_dev->ifname, fcf->vlan, config.suffix);
+ rc = snprintf(vlan_name, IFNAMSIZ, "%s.%d%s",
+ real_dev->ifname, fcf->vlan,
+ config.suffix);
+ if (rc < 0 || rc >= IFNAMSIZ) {
+ printf("Failed to create VLAN device "
+ "(name %s.%d%s is too long)\n",
+ real_dev->ifname, fcf->vlan,
+ config.suffix);
+ return -EINVAL;
+ }
rc = vlan_create(fcf->ifindex, fcf->vlan, vlan_name);
if (rc < 0)
printf("Failed to create VLAN device %s\n\t%s\n",
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化