1 Aug 2010 23:06
patch for crash in d-lang.c's demangler
Brad Roberts <braddr <at> puremagic.com>
2010-08-01 21:06:22 GMT
2010-08-01 21:06:22 GMT
There's a minor, but important bug in the d language symbol demangler. I
haven't reviewed the whole thing for other bugs, just the one that I hit.
I don't have a copyright assignment form on file, but hopefully this diff is
small enough to not require one. Consider the patch public domain or whatever
if that helps.
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 6db521b..f17431b 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
<at> <at> -37,8 +37,9 <at> <at> extract_identifiers (const char *mangled_str, struct obstack
*tempbuf)
while (isdigit (*mangled_str))
{
- i = strtol (mangled_str, NULL, 10);
- mangled_str++;
+ char * end_ptr;
+ i = strtol (mangled_str, &end_ptr, 10);
+ mangled_str = end_ptr;
if (i <= 0 && strlen (mangled_str) < i)
return 0;
obstack_grow (tempbuf, mangled_str, i);
Before this change, symbols with string fragments over 9 bytes long gets into a
bad state and might end up crashing. Certainly ends up with a bad string.
And example that crashes for me:
20src/core/atomic.d.9215__unittest_failFiZv
(Continue reading)
Comments inline below.
On Friday 02 July 2010 23:30:17, Kevin Buettner wrote:
> Index: remote-sim.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/remote-sim.c,v
> retrieving revision 1.96
> diff -u -p -r1.96 remote-sim.c
> --- remote-sim.c 16 May 2010 21:11:14 -0000 1.96
> +++ remote-sim.c 2 Jul 2010 20:15:59 -0000
> <at> <at> -101,19 +101,125 <at> <at> void simulator_command (char *args, int
> /* Forward data declarations */
> extern struct target_ops gdbsim_ops;
>
> -static int program_loaded = 0;
> +static const struct inferior_data *sim_inferior_data_key;
>
> -/* We must keep track of whether the simulator has been opened or not because
> - GDB can call a target's close routine twice, but sim_close doesn't allow
> - this. We also need to record the result of sim_open so we can pass it
> - back to the other sim_foo routines. */
> -static SIM_DESC gdbsim_desc = 0;
> -
> -/* This is the ptid we use while we're connected to the simulator.
> - Its value is arbitrary, as the simulator target don't have a notion
> - or processes or threads, but we need something non-null to place in
> - inferior_ptid. */
RSS Feed