diff options
author | Nick Clifton <nickc@redhat.com> | 2018-12-07 10:33:30 +0000 |
---|---|---|
committer | Nick Clifton <nickc@gcc.gnu.org> | 2018-12-07 10:33:30 +0000 |
commit | e96d1d8c7877ef25a2ef502b2685ba36b9913fd2 (patch) | |
tree | c7a769006e35e7c23d19c5fd82c84defb575f8bd /include | |
parent | 0876cb1c7b291db11e1de0b2b2b13b28152c5823 (diff) |
Add a recursion limit to libiberty's demangling code. The limit is enabled by default, but can be disabled via a new demangling option.
include * demangle.h (DMGL_NO_RECURSE_LIMIT): Define.
(DEMANGLE_RECURSION_LIMIT): Define
PR 87681
PR 87675
PR 87636
PR 87350
PR 87335
libiberty * cp-demangle.h (struct d_info): Add recursion_level field.
* cp-demangle.c (d_function_type): Add recursion counter.
If the recursion limit is reached and the check is not disabled,
then return with a failure result.
(cplus_demangle_init_info): Initialise the recursion_level field.
(d_demangle_callback): If the recursion limit is enabled, check
for a mangled string that is so long that there is not enough
stack space for the local arrays.
* cplus-dem.c (struct work): Add recursion_level field.
(squangle_mop_up): Set the numb and numk fields to zero.
(work_stuff_copy_to_from): Handle the case where a btypevec or
ktypevec field is NULL.
(demangle_nested_args): Add recursion counter. If
the recursion limit is not disabled and reached, return with a
failure result.
From-SVN: r266886
Diffstat (limited to 'include')
-rw-r--r-- | include/ChangeLog | 5 | ||||
-rw-r--r-- | include/demangle.h | 11 |
2 files changed, 16 insertions, 0 deletions
diff --git a/include/ChangeLog b/include/ChangeLog index d52f998b9b2..c26ddf4b4e3 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,8 @@ +2018-12-07 Nick Clifton <nickc@redhat.com> + + * demangle.h (DMGL_NO_RECURSE_LIMIT): Define. + (DEMANGLE_RECURSION_LIMIT): Define + 2018-11-08 Jakub Jelinek <jakub@redhat.com> * gomp-constants.h (GOMP_TASK_FLAG_REDUCTION, diff --git a/include/demangle.h b/include/demangle.h index 4f920f2b7f5..1e67fe2fb34 100644 --- a/include/demangle.h +++ b/include/demangle.h @@ -68,6 +68,17 @@ extern "C" { /* If none of these are set, use 'current_demangling_style' as the default. */ #define DMGL_STYLE_MASK (DMGL_AUTO|DMGL_GNU|DMGL_LUCID|DMGL_ARM|DMGL_HP|DMGL_EDG|DMGL_GNU_V3|DMGL_JAVA|DMGL_GNAT|DMGL_DLANG|DMGL_RUST) +/* Disable a limit on the depth of recursion in mangled strings. + Note if this limit is disabled then stack exhaustion is possible when + demangling pathologically complicated strings. Bug reports about stack + exhaustion when the option is enabled will be rejected. */ +#define DMGL_NO_RECURSE_LIMIT (1 << 18) + +/* If DMGL_NO_RECURSE_LIMIT is not enabled, then this is the value used as + the maximum depth of recursion allowed. It should be enough for any + real-world mangled name. */ +#define DEMANGLE_RECURSION_LIMIT 1024 + /* Enumeration of possible demangling styles. Lucid and ARM styles are still kept logically distinct, even though |