]> git.ipfire.org Git - thirdparty/gcc.git/commit
libiberty: Fix some demangler crashes caused by reading past end of input.
authorMark Wielaard <mark@klomp.org>
Tue, 15 Nov 2016 19:31:50 +0000 (19:31 +0000)
committerMark Wielaard <mark@gcc.gnu.org>
Tue, 15 Nov 2016 19:31:50 +0000 (19:31 +0000)
commit0d0bfbf47c67397b8380d5cd47aec8429888b196
treeac9185a03f861536fecb6507dcd0afa92608b55d
parent6f959acccbe249ca2cb24a473a132ab089c0f7eb
libiberty: Fix some demangler crashes caused by reading past end of input.

In various situations the cplus_demangle () function could read past the
end of input causing crashes. Add checks in various places to not advance
the demangle string location and fail early when end of string is reached.
Add various examples of input strings to the testsuite that would crash
test-demangle before the fixes.

Found by using the American Fuzzy Lop (afl) fuzzer.

libiberty/ChangeLog:

       * cplus-dem.c (demangle_signature): After 'H', template function,
       no success and don't advance position if end of string reached.
       (demangle_template): After 'z', template name, return zero on
       premature end of string.
       (gnu_special): Guard strchr against searching for zero characters.
       (do_type): If member, only advance mangled string when 'F' found.
       * testsuite/demangle-expected: Add examples of strings that could
       crash the demangler by reading past end of input.

From-SVN: r242450
libiberty/ChangeLog
libiberty/cplus-dem.c
libiberty/testsuite/demangle-expected