4 Star 2 Fork 11

src-openEuler/zlog

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0001-Fix-stack-buffer-overflow-at-zlog_conf_build_with_fi.patch 1.24 KB
一键复制 编辑 原始数据 按行查看 历史
Funda Wang 提交于 2024-10-30 21:06 +08:00 . 1.2.18
From 6c0823454ef075fedacf0b155e088ffc447985d6 Mon Sep 17 00:00:00 2001
From: yefeng <yefeng@kylinos.com.cn>
Date: Wed, 20 Apr 2022 13:43:22 +0800
Subject: [PATCH] Fix stack-buffer-overflow at zlog_conf_build_with_file
-#53811
---
src/conf.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/conf.c b/src/conf.c
index a947178..258a59a 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -375,6 +375,7 @@
*/
pline = line;
memset(&line, 0x00, sizeof(line));
+ //循环读取配置文件的一行
while (sgets(pline, MAXLEN_CFG_LINE, &conf_string_l) != NULL) {
++line_no;
line_len = strlen(pline);
@@ -399,12 +400,13 @@
for (p = pline + strlen(pline) - 1; isspace((int)*p); --p)
/*EMPTY*/;
+ //处理结束符为 '\\' 的特殊情况, 在这种情况下,当前行与下面一行并做一行处理
if (*p == '\\') {
if ((p - line) > MAXLEN_CFG_LINE - 30) {
/* Oops the buffer is full - what now? */
pline = line;
} else {
- for (p--; isspace((int)*p); --p)
+ for (p--; p >= line && isspace((int)*p); --p)
/*EMPTY*/;
p++;
*p = 0;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/zlog.git
git@gitee.com:src-openeuler/zlog.git
src-openeuler
zlog
zlog
master

搜索帮助