diff options
author | CoprDistGit <infra@openeuler.org> | 2024-09-18 07:05:42 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2024-09-18 07:05:42 +0000 |
commit | 4ad1d692311b38472d44f5deb9c32634b334ed4d (patch) | |
tree | 3e004676c8e07b495fdeda7291033d0fde73d783 /backport-Reset-recursion-depth-for-error-message.patch | |
parent | e248808867f90830a43b5ca5d192bef9dd2edec2 (diff) |
automatic import of rpm
Diffstat (limited to 'backport-Reset-recursion-depth-for-error-message.patch')
-rw-r--r-- | backport-Reset-recursion-depth-for-error-message.patch | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/backport-Reset-recursion-depth-for-error-message.patch b/backport-Reset-recursion-depth-for-error-message.patch new file mode 100644 index 0000000..4b5baee --- /dev/null +++ b/backport-Reset-recursion-depth-for-error-message.patch @@ -0,0 +1,81 @@ +From ef87d2503498f65577b5d7af07cd453d622fe02c Mon Sep 17 00:00:00 2001 +From: Florian Festi <ffesti@redhat.com> +Date: Thu, 18 Jul 2024 13:04:28 +0200 +Subject: [PATCH] Reset recursion depth for error message +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Conflict:adapt context +Reference:https://github.com/rpm-software-management/rpm/commit/ef87d2503498f65577b5d7af07cd453d622fe02c + +$ rpm --define 'aaa %[%aaa]' --eval '%aaa' + +let to a core dump due to a stack overflow. This was cause by the +generation of the error message failing due to being too deep in the +recursion of the macro expansion - creating more error messages. + +Resetting the depth counter allows rendering the error message. As we are +failing and breaking off the parse run this is fine to do. + +Thanks to Miro HronĨok for reporting + +Resolves: #3197 +--- + rpmio/macro.c | 4 +++- + tests/rpmmacro.at | 22 ++++++++++++++++++++++ + 2 files changed, 25 insertions(+), 1 deletion(-) + +diff --git a/rpmio/macro.c b/rpmio/macro.c +index b2fb1326d..3f34f718e 100644 +--- a/rpmio/macro.c ++++ b/rpmio/macro.c +@@ -447,9 +447,11 @@ static int mbInit(rpmMacroBuf mb, MacroExpansionData *med, size_t slen) + if (mb->buf == NULL) + mbAllocBuf(mb, slen); + if (++mb->depth > max_macro_depth) { ++ mb->depth--; ++ /* ensure error message can be rendered */ ++ mb->mc->depth = 0; + mbErr(mb, 1, + _("Too many levels of recursion in macro expansion. It is likely caused by recursive macro declaration.\n")); +- mb->depth--; + return -1; + } + med->tpos = mb->tpos; /* save expansion pointer for printExpand */ +diff --git a/tests/rpmmacro.at b/tests/rpmmacro.at +index 372cfa3ed..3adf48b61 100644 +--- a/tests/rpmmacro.at ++++ b/tests/rpmmacro.at +@@ -133,6 +133,28 @@ runroot rpm --define "this that" --define "that_that foo" --eval '%{expand:%{%{t + ]) + RPMTEST_CLEANUP + ++AT_SETUP([recursive macro]) ++AT_KEYWORDS([macros]) ++RPMTEST_CHECK([ ++runroot rpm --define 'aaa %aaa' --eval '%aaa' ++], ++[1], ++[], ++[error: Too many levels of recursion in macro expansion. It is likely caused by recursive macro declaration. ++]) ++RPMTEST_CLEANUP ++ ++AT_SETUP([recursive expression]) ++AT_KEYWORDS([macros]) ++RPMTEST_CHECK([ ++runroot rpm --define 'aaa %\\[%aaa\\]' --eval '%aaa' ++], ++[1], ++[], ++[error: Too many levels of recursion in macro expansion. It is likely caused by recursive macro declaration. ++]) ++RPMTEST_CLEANUP ++ + AT_SETUP([parametrized macro 1]) + AT_KEYWORDS([macros]) + RPMTEST_CHECK([ +-- +2.33.0 + |