RFA: Patch to fix severe recursion in d_count_templates_scopes (PR 89394)
Nick Clifton
nickc@redhat.com
Thu Mar 21 12:07:00 GMT 2019
Hi Ian,
Attached is a proposed patch to fix PR 89394, which contains an
artificial mangled name that triggers excessive recursion in
d_count_templates_scopes. The patch uses the same recursion limit
that is already in place for d_print_comp, which I hope will be
acceptable.
There is one frag in the patch which is not directly related to this
recursion problem however. It extends the check in
cplus_demangle_fill_name so that names with a negative length are
rejected. I had originally thought that the excessive recursion was
due to a negative length string, although further investigation proved
this guess to be wrong. I felt that leaving the check in however
would still be a good idea.
Tested with no regressions with an x86_64-linux-gnu toolchain, as well
as against the testcase in PR 89394.
OK to apply ?
Cheers
Nick
libiberty/ChangeLog
2019-03-21 Nick Clifton <nickc@redhat.com>
PR 89394
* cp-demangle.c (cplus_demangle_fill_name): Reject negative
lengths.
(d_count_templates_scopes): Replace num_templates and num_scopes
parameters with a struct d_print_info pointer parameter. Adjust
body of the function accordingly. Add recursion counter and check
that the recursion limit is not reached.
(d_print_init): Pass dpi parameter to d_count_templates_scopes.
Reset recursion counter afterwards, unless the recursion limit was
reached.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr89394.patch
Type: text/x-patch
Size: 3758 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20190321/436b5473/attachment.bin>
More information about the Gcc-patches
mailing list