public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "keiths at redhat dot com" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug gdb/30639] AddressSanitizer: dynamic-stack-buffer-overflow /home/root/sp/Dataset/Binutils/binutils_aflpp/gdb/ada-lang.c:1388:16 in ada_decode[abi:cxx11](char const*, bool, bool) Date: Tue, 15 Aug 2023 18:11:34 +0000 [thread overview] Message-ID: <bug-30639-4717-bvqcZt5bRl@http.sourceware.org/bugzilla/> (raw) In-Reply-To: <bug-30639-4717@http.sourceware.org/bugzilla/> https://sourceware.org/bugzilla/show_bug.cgi?id=30639 Keith Seitz <keiths at redhat dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2023-08-15 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #8 from Keith Seitz <keiths at redhat dot com> --- My apologies, this DOES reproduce (as Tom notes). The thing I ignored was ASAN. [The crash I reported was recently fixed by Alan Modra's "gdb: warn unused result for bfd IO functions".] [Probably TMI for Tom, but for anyone following along...] In process_coff_symbol, we are processing a symbol with name "44", i.e, just digits. The language of this objfile is language_unknown. process_coff_symbol calls general_symbol_info::compute_and_set_names. This eventually calls symbol_find_demangled_name with linkage_name_copy set to "44". Since the objfile's language is unknown, symbol_find_linkage_name iterates over all languages, calling the language's sniff_from_mangled_name method. This does nothing for all the languages until it hits language_ada. ada_language::sniff_from_mangled immediately calls ada_decode. The code here essentially skips to the last block which attempts to remove trailing digits: 1370 /* Remove trailing __{digit}+ or trailing ${digit}+. */ 1371 1372 if (len0 > 1 && isdigit (encoded[len0 - 1])) 1373 { 1374 i = len0 - 2; 1375 while ((i >= 0 && isdigit (encoded[i])) 1376 || (i >= 1 && encoded[i] == '_' && isdigit (encoded[i - 1]))) 1377 i -= 1; 1378 if (i > 1 && encoded[i] == '_' && encoded[i - 1] == '_') 1379 len0 = i - 1; 1380 else if (encoded[i] == '$') 1381 len0 = i; 1382 } When we get to 1372, len0 is strlen("44") which is 2. encoded[2 - 1] = "4" is a digit, and we set i = len0 - 2 = 0. Now the while loop: i == 0 and encoded[0] is "4", so that passes the first test, and we subtract 1 from i, setting it to -1. Now i is no longer >= 0 or >= 1, so the while loop escapes. Finally, we hit the final "else if" encoded[-1] == '$' on line 1380, which causes the observed buffer overflow. -- You are receiving this mail because: You are on the CC list for the bug.
next prev parent reply other threads:[~2023-08-15 18:11 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-07-15 6:26 [Bug gdb/30639] New: " sihan2021 at iscas dot ac.cn 2023-07-15 6:27 ` [Bug gdb/30639] " sihan2021 at iscas dot ac.cn 2023-07-26 19:15 ` keiths at redhat dot com 2023-07-29 5:35 ` sihan2021 at iscas dot ac.cn 2023-07-29 5:49 ` sihan2021 at iscas dot ac.cn 2023-07-29 5:49 ` sihan2021 at iscas dot ac.cn 2023-07-29 5:50 ` sihan2021 at iscas dot ac.cn 2023-07-29 15:15 ` tromey at sourceware dot org 2023-08-15 18:11 ` keiths at redhat dot com [this message] 2023-08-16 16:44 ` [Bug ada/30639] " tromey at sourceware dot org 2023-08-16 19:08 ` cvs-commit at gcc dot gnu.org 2023-08-16 19:11 ` tromey at sourceware dot org
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=bug-30639-4717-bvqcZt5bRl@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@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: linkBe 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; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).