1 Star 0 Fork 38

孙苏皖/iproute

forked from src-openEuler/iproute 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-lnstat-fix-buffer-overflow-in-header-output.patch 1.16 KB
一键复制 编辑 原始数据 按行查看 历史
孙苏皖 提交于 2022-08-26 17:33 . backport some patches from community
From be31c2648487596f23096278dacd86bf88305a14 Mon Sep 17 00:00:00 2001
From: "[200~jiangheng" <jiangheng12@huawei.com>
Date: Wed, 17 Nov 2021 13:41:10 -0800
Subject: [PATCH] lnstat: fix buffer overflow in header output
Running lnstat will cause core dump from reading past end of array.
Segmentation fault (core dumped)
The maximum value of th.num_lines is HDR_LINES(10), h should not be equal to th.num_lines, array th.hdr may be out of bounds.
Signed-off-by jiangheng <jiangheng12@huawei.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Conflict: NA
Reference: https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=be31c264848
---
misc/lnstat.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/misc/lnstat.c b/misc/lnstat.c
index 89cb0e7e..98904d45 100644
--- a/misc/lnstat.c
+++ b/misc/lnstat.c
@@ -210,8 +210,9 @@ static struct table_hdr *build_hdr_string(struct lnstat_file *lnstat_files,
}
ofs += width+1;
}
+
/* fill in spaces */
- for (h = 1; h <= th.num_lines; h++) {
+ for (h = 1; h < th.num_lines; h++) {
for (i = 0; i < ofs; i++) {
if (th.hdr[h][i] == '\0')
th.hdr[h][i] = ' ';
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sunsuwan/iproute.git
git@gitee.com:sunsuwan/iproute.git
sunsuwan
iproute
iproute
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385