mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-21 19:42:14 +00:00
GT-3481 - Gnu Demangler - Updated v2.24 to use prevent known
segmentation fault
This commit is contained in:
parent
f4e6f1294d
commit
b6fb46f5df
@ -145,7 +145,8 @@ model {
|
|||||||
println "have binary: " + b
|
println "have binary: " + b
|
||||||
|
|
||||||
if (version.equals(v33_1)) {
|
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_STDLIB_H"
|
||||||
cCompiler.args "-DHAVE_STRING_H"
|
cCompiler.args "-DHAVE_STRING_H"
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,9 @@
|
|||||||
|
|
||||||
|
|
||||||
CHANGE NOTICE:
|
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
|
/* This code implements a demangler for the g++ V3 ABI. The ABI is
|
||||||
@ -309,6 +311,11 @@ struct d_print_info
|
|||||||
int pack_index;
|
int pack_index;
|
||||||
/* Number of d_print_flush calls so far. */
|
/* Number of d_print_flush calls so far. */
|
||||||
unsigned long int flush_count;
|
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
|
#ifdef CP_DEMANGLE_DEBUG
|
||||||
@ -467,6 +474,12 @@ static inline char d_last_char (struct d_print_info *);
|
|||||||
static void
|
static void
|
||||||
d_print_comp (struct d_print_info *, int, const struct demangle_component *);
|
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
|
static void
|
||||||
d_print_java_identifier (struct d_print_info *, const char *, int);
|
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,
|
d_print_init (struct d_print_info *dpi, demangle_callbackref callback,
|
||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
|
|
||||||
dpi->len = 0;
|
dpi->len = 0;
|
||||||
dpi->last_char = '\0';
|
dpi->last_char = '\0';
|
||||||
dpi->templates = NULL;
|
dpi->templates = NULL;
|
||||||
@ -3678,6 +3692,10 @@ d_print_init (struct d_print_info *dpi, demangle_callbackref callback,
|
|||||||
dpi->opaque = opaque;
|
dpi->opaque = opaque;
|
||||||
|
|
||||||
dpi->demangle_failure = 0;
|
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. */
|
/* 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. */
|
/* 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
|
static void
|
||||||
d_print_comp (struct d_print_info *dpi, int options,
|
d_print_comp (struct d_print_info *dpi, int options,
|
||||||
const struct demangle_component *dc)
|
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
|
/* Magic variable to let reference smashing skip over the next modifier
|
||||||
without needing to modify *dc. */
|
without needing to modify *dc. */
|
||||||
const struct demangle_component *mod_inner = NULL;
|
const struct demangle_component *mod_inner = NULL;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
/* ###
|
/* ###
|
||||||
* IP: LGPL 3.0
|
* IP: LGPL 3.0
|
||||||
* REVIEWED: YES
|
|
||||||
*/
|
*/
|
||||||
/* Defs for interface to demanglers.
|
/* Defs for interface to demanglers.
|
||||||
Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002,
|
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. */
|
/* 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)
|
#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.
|
/* Enumeration of possible demangling styles.
|
||||||
|
|
||||||
Lucid and ARM styles are still kept logically distinct, even though
|
Lucid and ARM styles are still kept logically distinct, even though
|
||||||
|
Loading…
Reference in New Issue
Block a user