public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "amodra at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug demangler/103893] New: ada demangler heap overflow
Date: Mon, 03 Jan 2022 01:59:07 +0000 [thread overview]
Message-ID: <bug-103893-4@http.gcc.gnu.org/bugzilla/> (raw)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103893
Bug ID: 103893
Summary: ada demangler heap overflow
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: demangler
Assignee: unassigned at gcc dot gnu.org
Reporter: amodra at gmail dot com
Target Milestone: ---
>From https://sourceware.org/bugzilla/show_bug.cgi?id=28736
valgrind c++filt -s gnat vfffffSO__fffSO
==1573233== Invalid write of size 1
==1573233== at 0x4848DCC: strcpy (vg_replace_strmem.c:523)
==1573233== by 0x72688C: ada_demangle (cplus-dem.c:338)
==1573233== by 0x726ABA: cplus_demangle (cplus-dem.c:187)
==1573233== by 0x4038E8: demangle_it (cxxfilt.c:66)
==1573233== by 0x403AEC: main (cxxfilt.c:203)
==1573233== Address 0x4a60057 is 0 bytes after a block of size 23 alloc'd
==1573233== at 0x4842839: malloc (vg_replace_malloc.c:380)
==1573233== by 0x737A6B: xmalloc (xmalloc.c:147)
==1573233== by 0x726617: ada_demangle (cplus-dem.c:223)
==1573233== by 0x726ABA: cplus_demangle (cplus-dem.c:187)
==1573233== by 0x4038E8: demangle_it (cxxfilt.c:66)
==1573233== by 0x403AEC: main (cxxfilt.c:203)
The following comment in cplus-dem.c:ada_demangle is false for fuzzed input,
specifically the part that says "they occur only once".
/* Most of the demangling will trivially remove chars. Operator names
may add one char but because they are always preceeded by '__' which is
replaced by '.', they eventually never expand the size.
A few special names such as '___elabs' add a few chars (at most 7), but
they occur only once. */
len0 = strlen (mangled) + 7 + 1;
demangled = XNEWVEC (char, len0);
next reply other threads:[~2022-01-03 1:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-03 1:59 amodra at gmail dot com [this message]
2022-01-03 2:18 ` [Bug demangler/103893] " pinskia at gcc dot gnu.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-103893-4@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).