代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/rpm 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 856ddc334174fd37fe4ce81bc9f9f11a08cf6c81 Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
Date: Fri, 17 Mar 2023 12:53:42 +0200
Subject: [PATCH] Fix a segfault on a non-stringable argument to macro call
from Lua
When natively calling a parametric macro from Lua, with the arguments
inside a table, we can't assume lua_tostring() always succeeds as it
can fail eg on a table. Report the error instead of crashing in argvAdd(),
and add a test as well.
---
rpmio/rpmlua.c | 9 +++++++--
tests/rpmmacro.at | 9 +++++++++
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/rpmio/rpmlua.c b/rpmio/rpmlua.c
index 6c42af792..0e3685713 100644
--- a/rpmio/rpmlua.c
+++ b/rpmio/rpmlua.c
@@ -1178,8 +1178,13 @@ static int mc_call(lua_State *L)
for (int i = 1; i <= nitem; i++) {
lua_rawgeti(L, 1, i);
- argvAdd(&argv, lua_tostring(L, -1));
- lua_pop(L, 1);
+ const char *s= lua_tostring(L, -1);
+ if (s) {
+ argvAdd(&argv, s);
+ lua_pop(L, 1);
+ } else {
+ luaL_argerror(L, i, "cannot convert to string");
+ }
}
if (rpmExpandThisMacro(*mc, name, argv, &buf, 0) >= 0) {
diff --git a/tests/rpmmacro.at b/tests/rpmmacro.at
index 55b7d5fa5..22d873e81 100644
--- a/tests/rpmmacro.at
+++ b/tests/rpmmacro.at
@@ -713,6 +713,15 @@ nil
1:%{?aaa} 2:%{yyy}
that
])
+
+AT_CHECK([[
+runroot rpm \
+ --eval "%{lua:macros.defined({1,2,{}})}"
+]],
+[1],
+[],
+[[error: lua script failed: [string "<lua>"]:1: bad argument #3 to 'defined' (cannot convert to string)
+]])
AT_CLEANUP
AT_SETUP([lua macros recursion])
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。