Go to file
Alan Modra fff56ce438 ubsan: d-demangle.c:214 signed integer overflow
Running the libiberty testsuite
./test-demangle < libiberty/testsuite/d-demangle-expected
libiberty/d-demangle.c:214:14: runtime error: signed integer overflow: 922337203 * 10 cannot be represented in type 'long int'

On looking at silencing ubsan, I found a real bug in dlang_number.
For a 32-bit long, some overflows won't be detected.  For example,
21474836480.  Why?  Well 214748364 * 10 is 0x7FFFFFF8 (no overflow so
far).  Adding 8 gives 0x80000000 (which does overflow but there is no
test for that overflow in the code).  Then multiplying 0x80000000 * 10
= 0x500000000 = 0 won't be caught by the multiplication overflow test.
The same holds for a 64-bit long using similarly crafted digit
sequences.

	* d-demangle.c: Include limits.h.
	(ULONG_MAX, UINT_MAX): Provide fall-back definition.
	(dlang_number): Simplify and correct overflow test.  Only
	write *ret on returning non-NULL.  Make "ret" an unsigned long*.
	Only succeed for result of [0,UINT_MAX].
	(dlang_decode_backref): Simplify and correct overflow test.
	Only write *ret on returning non-NULL.  Only succeed for
	result [1,MAX_LONG].
	(dlang_backref): Remove now unnecessary range check.
	(dlang_symbol_name_p): Likewise.
	(string_need): Take a size_t n arg, and use size_t tem.
	(string_append): Use size_t n.
	(string_appendn, string_prependn): Take a size_t n arg.
	(TEMPLATE_LENGTH_UNKNOWN): Define as -1UL.
	(dlang_lname, dlang_parse_template): Take an unsigned long len
	arg.
	(dlang_symbol_backref, dlang_identifier, dlang_parse_integer),
	(dlang_parse_integer, dlang_parse_string),
	(dlang_parse_arrayliteral, dlang_parse_assocarray),
	(dlang_parse_structlit, dlang_parse_tuple),
	(dlang_template_symbol_param, dlang_template_args): Use
	unsigned long variables.
	* testsuite/d-demangle-expected: Add new tests.
2020-09-08 10:45:15 +09:30
INSTALL
config Daily bump. 2020-08-21 00:16:23 +00:00
contrib Daily bump. 2020-08-27 00:16:27 +00:00
fixincludes
gcc Daily bump. 2020-09-08 00:16:32 +00:00
gnattools
gotools
include
intl
libada
libatomic Daily bump. 2020-09-08 00:16:32 +00:00
libbacktrace Daily bump. 2020-08-25 00:16:24 +00:00
libcc1 Daily bump. 2020-08-15 00:16:22 +00:00
libcpp Daily bump. 2020-09-08 00:16:32 +00:00
libdecnumber
libffi
libgcc Daily bump. 2020-08-27 00:16:27 +00:00
libgfortran Daily bump. 2020-09-04 00:16:32 +00:00
libgo gotest: use a space rather than a middle dot in target lists 2020-08-27 16:18:01 -07:00
libgomp Daily bump. 2020-08-21 00:16:23 +00:00
libhsail-rt
libiberty ubsan: d-demangle.c:214 signed integer overflow 2020-09-08 10:45:15 +09:30
libitm
libobjc
liboffloadmic
libphobos
libquadmath
libsanitizer
libssp
libstdc++-v3 Daily bump. 2020-09-08 00:16:32 +00:00
libvtv
lto-plugin
maintainer-scripts
zlib
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
ChangeLog Daily bump. 2020-08-27 00:16:27 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
MAINTAINERS MAINTAINERS: Add myself as OpenACC maintainer 2020-08-26 17:58:22 +02:00
Makefile.def
Makefile.in
Makefile.tpl
README
ar-lib
compile
config-ml.in
config.guess
config.rpath
config.sub
configure configure: Also check C++11 (flags) for ${build} compiler not only for ${host} 2020-08-20 21:59:00 +02:00
configure.ac configure: Also check C++11 (flags) for ${build} compiler not only for ${host} 2020-08-20 21:59:00 +02:00
depcomp
install-sh
libtool-ldflags
libtool.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
symlink-tree
test-driver
ylwrap

README

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.