GT-3481 - Gnu Demangler - Updated v2.24 to use prevent known

segmentation fault
This commit is contained in:
dragonmacher 2020-02-07 16:02:58 -05:00
parent f4e6f1294d
commit b6fb46f5df
3 changed files with 42 additions and 3 deletions

View file

@ -145,7 +145,8 @@ model {
println "have binary: " + b
if (version.equals(v33_1)) {
if (toolChain in Gcc) {
if (toolChain in Gcc) {
//cCompiler.args "-DCP_DEMANGLE_DEBUG"
cCompiler.args "-DHAVE_STDLIB_H"
cCompiler.args "-DHAVE_STRING_H"
}

View file

@ -33,7 +33,9 @@
CHANGE NOTICE:
This file was changed on July 22nd, 2020.
This file was changed on July 22nd, 2020
This file was changed on Jan 22, 2020
- Added a method to wrap calls to d_print_comp() in order to track too much recursion
*/
/* This code implements a demangler for the g++ V3 ABI. The ABI is
@ -309,6 +311,11 @@ struct d_print_info
int pack_index;
/* Number of d_print_flush calls so far. */
unsigned long int flush_count;
// Changed Jan 22, 2020 - Added a method to wrap calls to d_print_comp() in
// order to track too much recursion
int recursion_level;
};
#ifdef CP_DEMANGLE_DEBUG
@ -467,6 +474,12 @@ static inline char d_last_char (struct d_print_info *);
static void
d_print_comp (struct d_print_info *, int, const struct demangle_component *);
// Changed Jan 22, 2020 - Added a method to wrap calls to d_print_comp() in
// order to track too much recursion
static void
d_print_comp_delegate (struct d_print_info *, int, const struct demangle_component *);
static void
d_print_java_identifier (struct d_print_info *, const char *, int);
@ -3667,6 +3680,7 @@ static void
d_print_init (struct d_print_info *dpi, demangle_callbackref callback,
void *opaque)
{
dpi->len = 0;
dpi->last_char = '\0';
dpi->templates = NULL;
@ -3678,6 +3692,10 @@ d_print_init (struct d_print_info *dpi, demangle_callbackref callback,
dpi->opaque = opaque;
dpi->demangle_failure = 0;
// Changed Jan 22, 2020 - Added a method to wrap calls to d_print_comp() in
// order to track too much recursion
dpi->recursion_level = 0;
}
/* Indicate that an error occurred during printing, and test for error. */
@ -3928,10 +3946,28 @@ d_print_subexpr (struct d_print_info *dpi, int options,
/* Subroutine to handle components. */
// Changed Jan 22, 2020 - Added a method to wrap calls to d_print_comp() in
// order to track too much recursion
static void
d_print_comp (struct d_print_info *dpi, int options,
const struct demangle_component *dc)
{
if (dpi->recursion_level > DEMANGLE_RECURSION_LIMIT) {
d_print_error (dpi);
return;
}
dpi->recursion_level++;
d_print_comp_delegate(dpi, options, dc);
dpi->recursion_level--;
}
static void
d_print_comp_delegate (struct d_print_info *dpi, int options,
const struct demangle_component *dc)
{
/* Magic variable to let reference smashing skip over the next modifier
without needing to modify *dc. */
const struct demangle_component *mod_inner = NULL;

View file

@ -1,6 +1,5 @@
/* ###
* IP: LGPL 3.0
* REVIEWED: YES
*/
/* Defs for interface to demanglers.
Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002,
@ -71,6 +70,9 @@ 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)
// Changed Jan 22, 2020 - Added constant to allow us to limit degenerate recursive calls
#define DEMANGLE_RECURSION_LIMIT 10000
/* Enumeration of possible demangling styles.
Lucid and ARM styles are still kept logically distinct, even though