|
|
@ -1,14 +1,15 @@
|
|
|
|
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
|
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
|
From: Nick Clifton <nickc@redhat.com>
|
|
|
|
From: Keith Seitz <keiths@redhat.com>
|
|
|
|
Date: Fri, 1 Jul 2022 15:58:52 +0100
|
|
|
|
Date: Thu, 12 Oct 2023 15:03:51 -0400
|
|
|
|
Subject: libiberty-infinite-recursion-fix-1-of-2.patch
|
|
|
|
Subject: gdb-rhel-4237-rust-demangler-recursion-limit-1of2.patch
|
|
|
|
|
|
|
|
|
|
|
|
;; Backport Add a recursion limit to the demangle_const function in the Rust demangler.
|
|
|
|
;; Backport "Add a recursion limit to the demangle_const function
|
|
|
|
;; (Nick Clifton, RHEL-4234)
|
|
|
|
;; in the Rust demangler."
|
|
|
|
|
|
|
|
;; (Nick Clifton, RHEL-4237)
|
|
|
|
|
|
|
|
|
|
|
|
libiberty/
|
|
|
|
libiberty/
|
|
|
|
PR demangler/105039
|
|
|
|
PR demangler/105039
|
|
|
|
* rust-demangle.c (demangle_const): Add recursion limit.
|
|
|
|
* rust-demangle.c (demangle_const): Add recursion limit.
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c
|
|
|
|
diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c
|
|
|
|
--- a/libiberty/rust-demangle.c
|
|
|
|
--- a/libiberty/rust-demangle.c
|
|
|
@ -22,7 +23,38 @@ diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c
|
|
|
|
{
|
|
|
|
{
|
|
|
|
c = next (rdm);
|
|
|
|
c = next (rdm);
|
|
|
|
x *= 62;
|
|
|
|
x *= 62;
|
|
|
|
@@ -1148,6 +1148,15 @@ demangle_const (struct rust_demangler *rdm)
|
|
|
|
@@ -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 recursion limit has been reached. */
|
|
|
|
|
|
|
|
+ rdm->errored = 1;
|
|
|
|
|
|
|
|
+ goto end_of_func;
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
if (eat (rdm, 'B'))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
backref = parse_integer_62 (rdm);
|
|
|
|
|
|
|
|
@@ -1107,6 +1119,11 @@ 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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1148,6 +1165,15 @@ demangle_const (struct rust_demangler *rdm)
|
|
|
|
if (rdm->errored)
|
|
|
|
if (rdm->errored)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
@ -38,7 +70,7 @@ diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c
|
|
|
|
if (eat (rdm, 'B'))
|
|
|
|
if (eat (rdm, 'B'))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
backref = parse_integer_62 (rdm);
|
|
|
|
backref = parse_integer_62 (rdm);
|
|
|
|
@@ -1158,7 +1167,7 @@ demangle_const (struct rust_demangler *rdm)
|
|
|
|
@@ -1158,7 +1184,7 @@ demangle_const (struct rust_demangler *rdm)
|
|
|
|
demangle_const (rdm);
|
|
|
|
demangle_const (rdm);
|
|
|
|
rdm->next = old_next;
|
|
|
|
rdm->next = old_next;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -47,7 +79,7 @@ diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ty_tag = next (rdm);
|
|
|
|
ty_tag = next (rdm);
|
|
|
|
@@ -1167,7 +1176,7 @@ demangle_const (struct rust_demangler *rdm)
|
|
|
|
@@ -1167,7 +1193,7 @@ demangle_const (struct rust_demangler *rdm)
|
|
|
|
/* Placeholder. */
|
|
|
|
/* Placeholder. */
|
|
|
|
case 'p':
|
|
|
|
case 'p':
|
|
|
|
PRINT ("_");
|
|
|
|
PRINT ("_");
|
|
|
@ -56,7 +88,7 @@ diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c
|
|
|
|
|
|
|
|
|
|
|
|
/* Unsigned integer types. */
|
|
|
|
/* Unsigned integer types. */
|
|
|
|
case 'h':
|
|
|
|
case 'h':
|
|
|
|
@@ -1200,18 +1209,20 @@ demangle_const (struct rust_demangler *rdm)
|
|
|
|
@@ -1200,18 +1226,20 @@ demangle_const (struct rust_demangler *rdm)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|