public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-1452] Prevent another potential stack overflow issue when demangling a maliciouslt mangled Rust name.
@ 2022-07-04 10:06 Nick Clifton
0 siblings, 0 replies; only message in thread
From: Nick Clifton @ 2022-07-04 10:06 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:1a770b01ef415e114164b6151d1e55acdee09371
commit r13-1452-g1a770b01ef415e114164b6151d1e55acdee09371
Author: Nick Clifton <nickc@redhat.com>
Date: Mon Jul 4 11:05:03 2022 +0100
Prevent another potential stack overflow issue when demangling a maliciouslt mangled Rust name.
libiberty/
* rust-demangle.c (demangle_path_maybe_open_generics): Add
recursion limit.
Diff:
---
libiberty/rust-demangle.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c
index 36afcfae278..d6daf23af27 100644
--- 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 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;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-07-04 10:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-04 10:06 [gcc r13-1452] Prevent another potential stack overflow issue when demangling a maliciouslt mangled Rust name Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).