1 Star 0 Fork 63

桐小哥 / rpm

forked from src-openEuler / rpm 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-Fix-logic-error-in-grabArgs.patch 1.42 KB
一键复制 编辑 原始数据 按行查看 历史
Liquor 提交于 2021-01-11 11:10 . backport patches from upstream
From 6d7fa91949337c7a86bab3359b39558fdae07dce Mon Sep 17 00:00:00 2001
From: Michael Schroeder <mls@suse.de>
Date: Fri, 23 Oct 2020 14:02:35 +0200
Subject: [PATCH] Fix logic error in grabArgs()
If there was a \ at the end of the buffer, the code would
return a pointer after the trailing \0 leading to unallocated
memory access and weird results in some cases.
See commit 817959609b95afe34ce0f7f6c3dc5d7d0d9a8470.
---
rpmio/macro.c | 2 +-
tests/rpmmacro.at | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/rpmio/macro.c b/rpmio/macro.c
index 1edcb39e6..a1ed9b288 100644
--- a/rpmio/macro.c
+++ b/rpmio/macro.c
@@ -947,7 +947,7 @@ grabArgs(MacroBuf mb, const rpmMacroEntry me, const char * se,
splitQuoted(&argv, s, " \t");
free(s);
- cont = ((*lastc == '\0' || *lastc == '\n') && *(lastc-1) != '\\') ?
+ cont = (*lastc == '\0') || (*lastc == '\n' && *(lastc-1) != '\\') ?
lastc : lastc + 1;
}
diff --git a/tests/rpmmacro.at b/tests/rpmmacro.at
index d972a1197..a21952c46 100644
--- a/tests/rpmmacro.at
+++ b/tests/rpmmacro.at
@@ -179,6 +179,9 @@ runroot rpm \
--eval '%foo %{quote: 2 3 5} %{quote:%{nil}}' \
--eval '%foo x%{quote:y}z 123' \
--eval '%foo x%{quote:%{nil}}z' \
+ --eval '%foo 1 \
+bar' \
+ --eval '%foo 1 \' \
],
[0],
[1:"1"
@@ -190,6 +193,8 @@ runroot rpm \
2:" 2 3 5" ""
2:"xyz" "123"
1:"xz"
+2:"1" "\"bar
+2:"1" "\"
])
AT_CLEANUP
--
2.27.0
1
https://gitee.com/tong_1001/rpm.git
git@gitee.com:tong_1001/rpm.git
tong_1001
rpm
rpm
master

搜索帮助