Fix issue introduced when backporting recursion limit to rust demangler

Resolves: RHEL-7330
This commit is contained in:
Guinevere Larsen 2023-10-30 12:54:25 +01:00
parent 9e868de349
commit 0d467c05d6
5 changed files with 49 additions and 1 deletions

View File

@ -301,3 +301,6 @@ Patch070: libiberty-infinite-recursion-fix-1-of-2.patch
# (Nick Clifton)
Patch071: libiberty-infinite-recursion-fix-2-of-2.patch
Patch072: libiberty-infinite-recursion-fix-3-of-3.patch

View File

@ -69,3 +69,4 @@
%patch069 -p1
%patch070 -p1
%patch071 -p1
%patch072 -p1

View File

@ -69,3 +69,4 @@ gdb-backport-call-check_typedef-at-beginning-of-dwarf_expr_context.patch
gdb-rhbz2153228-fail-if-sh_info-is-zero.patch
libiberty-infinite-recursion-fix-1-of-2.patch
libiberty-infinite-recursion-fix-2-of-2.patch
libiberty-infinite-recursion-fix-3-of-3.patch

View File

@ -73,7 +73,7 @@ Version: 12.1
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
Release: 4%{?dist}
Release: 5%{?dist}
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and LGPLv3+ and BSD and Public Domain and GFDL
# Do not provide URL for snapshots as the file lasts there only for 2 days.
@ -1205,6 +1205,9 @@ fi
%endif
%changelog
* Mon Oct 30 2023 Guinevere Larsen <blarsen@redhat.com> - 12.1-5.el9
- Fix issue introduced when backporting the recursion limit to the rust demangler.
* Tue Oct 10 2023 Guinevere Larsen <blarsen@redhat.com> - 12.1-4.el9
- Backport "Fix typo in recent code to add stack recursion limit to the Rust demangler."
(Nick Clifton)

View File

@ -0,0 +1,40 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Guinevere Larsen <blarsen@redhat.com>
Date: Mon, 30 Oct 2023 12:48:01 +0100
Subject: libiberty-infinite-recursion-fix-3-of-3.patch
fix backport error in patch 1 of this series.
diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c
--- a/libiberty/rust-demangle.c
+++ b/libiberty/rust-demangle.c
@@ -1082,6 +1082,18 @@ demangle_path_maybe_open_generics (struct rust_demangler *rdm)
if (rdm->errored)
return open;
+ if (rdm->recursion != RUST_NO_RECURSION_LIMIT)
+ {
+ ++ rdm ->recursion;
+ if (rdm->recursion > RUST_MAX_RECURSION_COUNT)
+ {
+ /* FIXME: there ought to be a way to report
+ that the recorsion limit has been reached. */
+ rdm->errored = 1;
+ goto end_of_func;
+ }
+ }
+
if (eat (rdm, 'B'))
{
backref = parse_integer_62 (rdm);
@@ -1107,6 +1119,10 @@ demangle_path_maybe_open_generics (struct rust_demangler *rdm)
}
else
demangle_path (rdm, 0);
+ end_of_func:
+ if (rdm->recursion != RUST_NO_RECURSION_LIMIT)
+ -- rdm->recursion;
+
return open;
}