1 Star 0 Fork 41

lishiyangasdf/kexec-tools

forked from src-openEuler/kexec-tools 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
kexec-tools-Fix-possible-out-of-bounds-access-in-ifdown.patch 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
From 775f258fbd1895ba669be22f108faf817247a47a Mon Sep 17 00:00:00 2001
From: Helge Deller <deller@gmx.de>
Date: Tue, 1 Oct 2019 17:06:05 +0200
Subject: [PATCH] kexec-tools: Fix possible out-of-bounds access in ifdown
Fix a possible out-of-bounds access in function ifdown():
ifdown.c: In function 'ifdown':
ifdown.c:56:4: warning: 'strncpy' specified bound 16 equals destination size [-Wstringop-truncation]
56 | strncpy(ifr.ifr_name, ifp->if_name, IFNAMSIZ);
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Simon Horman <horms@verge.net.au>
diff --git a/kexec/ifdown.c b/kexec/ifdown.c
index 9679ad7..3ac19c1 100644
--- a/kexec/ifdown.c
+++ b/kexec/ifdown.c
@@ -53,7 +53,8 @@ int ifdown(void)
if (strchr(ifp->if_name, ':') != NULL)
continue;
- strncpy(ifr.ifr_name, ifp->if_name, IFNAMSIZ);
+ strncpy(ifr.ifr_name, ifp->if_name, IFNAMSIZ-1);
+ ifr.ifr_name[IFNAMSIZ-1] = 0;
if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
fprintf(stderr, "ifdown: shutdown ");
perror(ifp->if_name);
--
1.8.3.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lishiyangasdf/kexec-tools.git
git@gitee.com:lishiyangasdf/kexec-tools.git
lishiyangasdf
kexec-tools
kexec-tools
master

搜索帮助