parent
b8596c2486
commit
054710fcc5
@ -0,0 +1,85 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Nick Clifton <nickc@redhat.com>
|
||||
Date: Fri, 1 Jul 2022 15:58:52 +0100
|
||||
Subject: libiberty-infinite-recursion-fix-1-of-2.patch
|
||||
|
||||
;; Backport Add a recursion limit to the demangle_const function in the Rust demangler.
|
||||
;; (Nick Clifton, RHEL-4234)
|
||||
|
||||
libiberty/
|
||||
PR demangler/105039
|
||||
* rust-demangle.c (demangle_const): Add recursion limit.
|
||||
|
||||
diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c
|
||||
--- a/libiberty/rust-demangle.c
|
||||
+++ b/libiberty/rust-demangle.c
|
||||
@@ -126,7 +126,7 @@ parse_integer_62 (struct rust_demangler *rdm)
|
||||
return 0;
|
||||
|
||||
x = 0;
|
||||
- while (!eat (rdm, '_'))
|
||||
+ while (!eat (rdm, '_') && !rdm->errored)
|
||||
{
|
||||
c = next (rdm);
|
||||
x *= 62;
|
||||
@@ -1148,6 +1148,15 @@ demangle_const (struct rust_demangler *rdm)
|
||||
if (rdm->errored)
|
||||
return;
|
||||
|
||||
+ 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. */
|
||||
+ goto fail_return;
|
||||
+ }
|
||||
+
|
||||
if (eat (rdm, 'B'))
|
||||
{
|
||||
backref = parse_integer_62 (rdm);
|
||||
@@ -1158,7 +1167,7 @@ demangle_const (struct rust_demangler *rdm)
|
||||
demangle_const (rdm);
|
||||
rdm->next = old_next;
|
||||
}
|
||||
- return;
|
||||
+ goto pass_return;
|
||||
}
|
||||
|
||||
ty_tag = next (rdm);
|
||||
@@ -1167,7 +1176,7 @@ demangle_const (struct rust_demangler *rdm)
|
||||
/* Placeholder. */
|
||||
case 'p':
|
||||
PRINT ("_");
|
||||
- return;
|
||||
+ goto pass_return;
|
||||
|
||||
/* Unsigned integer types. */
|
||||
case 'h':
|
||||
@@ -1200,18 +1209,20 @@ demangle_const (struct rust_demangler *rdm)
|
||||
break;
|
||||
|
||||
default:
|
||||
- rdm->errored = 1;
|
||||
- return;
|
||||
+ goto fail_return;
|
||||
}
|
||||
|
||||
- if (rdm->errored)
|
||||
- return;
|
||||
-
|
||||
- if (rdm->verbose)
|
||||
+ if (!rdm->errored && rdm->verbose)
|
||||
{
|
||||
PRINT (": ");
|
||||
PRINT (basic_type (ty_tag));
|
||||
}
|
||||
+
|
||||
+ fail_return:
|
||||
+ rdm->errored = 1;
|
||||
+ pass_return:
|
||||
+ if (rdm->recursion != RUST_NO_RECURSION_LIMIT)
|
||||
+ -- rdm->recursion;
|
||||
}
|
||||
|
||||
static void
|
@ -0,0 +1,23 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Nick Clifton <nickc@redhat.com>
|
||||
Date: Mon, 4 Jul 2022 16:31:18 +0100
|
||||
Subject: libiberty-infinite-recursion-fix-2-of-2.patch
|
||||
|
||||
;; Backport Fix typo in recent code to add stack recursion limit to the Rust demangler.
|
||||
;; (Nick Clifton)
|
||||
|
||||
libiberty
|
||||
* rust-demangle.c (demangle_const): Add a missing goto pass_return
|
||||
at the end of the function.
|
||||
|
||||
diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c
|
||||
--- a/libiberty/rust-demangle.c
|
||||
+++ b/libiberty/rust-demangle.c
|
||||
@@ -1217,6 +1217,7 @@ demangle_const (struct rust_demangler *rdm)
|
||||
PRINT (": ");
|
||||
PRINT (basic_type (ty_tag));
|
||||
}
|
||||
+ goto pass_return;
|
||||
|
||||
fail_return:
|
||||
rdm->errored = 1;
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in new issue