!236 Sync Pr-232:Fix a segfault on a non-stringable argument to macro call from Lua
From: @renxichen Reviewed-by: @xujing99 Signed-off-by: @xujing99
This commit is contained in:
commit
3fbfd5c797
@ -0,0 +1,58 @@
|
|||||||
|
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.27.0
|
||||||
|
|
||||||
6
rpm.spec
6
rpm.spec
@ -1,6 +1,6 @@
|
|||||||
Name: rpm
|
Name: rpm
|
||||||
Version: 4.18.0
|
Version: 4.18.0
|
||||||
Release: 9
|
Release: 10
|
||||||
Summary: RPM Package Manager
|
Summary: RPM Package Manager
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
URL: http://www.rpm.org/
|
URL: http://www.rpm.org/
|
||||||
@ -39,6 +39,7 @@ Patch6016: backport-Add-a-test-for-special-device-node-installation.patch
|
|||||||
Patch6017: backport-support-for-POSIX-getopt-behaviour.patch
|
Patch6017: backport-support-for-POSIX-getopt-behaviour.patch
|
||||||
Patch6018: backport-Use-proper-type-for-copyTagsFromMainDebug.patch
|
Patch6018: backport-Use-proper-type-for-copyTagsFromMainDebug.patch
|
||||||
Patch6019: backport-Fix-a-copy-paste-help-description-of-whatconflicts-R.patch
|
Patch6019: backport-Fix-a-copy-paste-help-description-of-whatconflicts-R.patch
|
||||||
|
Patch6020: backport-Fix-a-segfault-on-a-non-stringable-argument-to-macro.patch
|
||||||
|
|
||||||
Patch9000: Add-digest-list-plugin.patch
|
Patch9000: Add-digest-list-plugin.patch
|
||||||
Patch9001: Add-IMA-digest-list-support.patch
|
Patch9001: Add-IMA-digest-list-support.patch
|
||||||
@ -328,6 +329,9 @@ make clean
|
|||||||
%exclude %{_mandir}/man8/rpmspec.8.gz
|
%exclude %{_mandir}/man8/rpmspec.8.gz
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Jun 19 2023 renhongxun<renhongxun@h-partners.com> - 4.18.0-10
|
||||||
|
- Fix a segfault on a non-stringable argument to macro call from Lua
|
||||||
|
|
||||||
* Fri Jun 16 2023 zhoushuiqing<zhoushuiqing2@huawei.com> - 4.18.0-9
|
* Fri Jun 16 2023 zhoushuiqing<zhoushuiqing2@huawei.com> - 4.18.0-9
|
||||||
* Add digest list plugin support
|
* Add digest list plugin support
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user