Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Brad Roberts <braddr@puremagic.com>
To: gdb-patches@sourceware.org
Subject: patch for crash in d-lang.c's demangler
Date: Sun, 01 Aug 2010 21:10:00 -0000	[thread overview]
Message-ID: <4C55E1CE.5000301@puremagic.com> (raw)

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
@@ -37,8 +37,9 @@ 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

Thanks,
Brad


             reply	other threads:[~2010-08-01 21:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-01 21:10 Brad Roberts [this message]
2010-08-10 22:17 ` Tom Tromey
2010-08-10 23:15   ` Brad Roberts
2010-08-11  1:52     ` Tom Tromey
2010-08-11 15:41       ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C55E1CE.5000301@puremagic.com \
    --to=braddr@puremagic.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox