binutils-gdb/libctf
Nick Alcock 9323dd869d libctf: make ctf_dump not crash on OOM
ctf_dump calls ctf_str_append extensively but never checks to see if it
returns NULL (on OOM).  If it ever does, we truncate the string we are
appending to and leak it!

Instead, create a variant of ctf_str_append that returns the *original
string* on OOM, and use it in ctf-dump.  It is far better to omit a tiny
piece of a dump on OOM than to omit a bigger piece, and it is also
better to do this in what is after all purely debugging code than it is
to uglify ctf-dump.c with huge numbers of checks for the out-of-memory
case.  Slightly truncated debugging output is better than no debugging
output at all and an out-of-memory message.

New in v4.

libctf/
	* ctf-impl.h (ctf_str_append_noerr): Declare.
	* ctf-util.c (ctf_str_append_noerr): Define in terms of
	ctf_str_append.
	* ctf-dump.c (str_append): New, call it.
	(ctf_dump_format_type): Use str_append, not ctf_str_append.
	(ctf_dump_label): Likewise.
	(ctf_dump_objts): Likewise.
	(ctf_dump_funcs): Likewise.
	(ctf_dump_var): Likewise.
	(ctf_dump_member): Likewise.
	(ctf_dump_type): Likewise.
	(ctf_dump): Likewise.
2019-10-03 17:04:56 +01:00
..
aclocal.m4 libctf: installable libctf as a shared library 2019-10-03 17:04:56 +01:00
ChangeLog libctf: make ctf_dump not crash on OOM 2019-10-03 17:04:56 +01:00
config.h.in libctf: installable libctf as a shared library 2019-10-03 17:04:56 +01:00
configure libctf: installable libctf as a shared library 2019-10-03 17:04:56 +01:00
configure.ac libctf: installable libctf as a shared library 2019-10-03 17:04:56 +01:00
ctf-archive.c libctf: avoid the need to ever use ctf_update 2019-10-03 17:04:56 +01:00
ctf-create.c libctf: remove ctf_malloc, ctf_free and ctf_strdup 2019-10-03 17:04:56 +01:00
ctf-decl.c libctf: remove ctf_malloc, ctf_free and ctf_strdup 2019-10-03 17:04:56 +01:00
ctf-decls.h libctf: avoid strndup 2019-06-07 13:46:39 +01:00
ctf-dump.c libctf: make ctf_dump not crash on OOM 2019-10-03 17:04:56 +01:00
ctf-endian.h libctf: make it compile for old glibc 2019-10-03 17:04:55 +01:00
ctf-error.c libctf: handle nonrepresentable types at link time 2019-10-03 17:04:56 +01:00
ctf-hash.c libctf: don't leak hash keys or values on value replacement 2019-10-03 17:04:55 +01:00
ctf-impl.h libctf: make ctf_dump not crash on OOM 2019-10-03 17:04:56 +01:00
ctf-labels.c libctf: fix a number of build problems found on Solaris and NetBSD 2019-05-31 11:10:51 +02:00
ctf-link.c libctf: avoid the need to ever use ctf_update 2019-10-03 17:04:56 +01:00
ctf-lookup.c libctf: avoid the need to ever use ctf_update 2019-10-03 17:04:56 +01:00
ctf-open-bfd.c libctf: actually close bfds we have opened 2019-10-03 17:04:55 +01:00
ctf-open.c libctf: remove ctf_malloc, ctf_free and ctf_strdup 2019-10-03 17:04:56 +01:00
ctf-qsort_r.c libctf: look for BSD versus GNU qsort_r signatures 2019-06-04 17:05:08 +01:00
ctf-string.c libctf: remove ctf_malloc, ctf_free and ctf_strdup 2019-10-03 17:04:56 +01:00
ctf-subr.c libctf: remove ctf_malloc, ctf_free and ctf_strdup 2019-10-03 17:04:56 +01:00
ctf-types.c libctf: get the encoding of non-ints/fps in the dynamic space right 2019-10-03 17:04:56 +01:00
ctf-util.c libctf: make ctf_dump not crash on OOM 2019-10-03 17:04:56 +01:00
elf.h
libctf.ver libctf: installable libctf as a shared library 2019-10-03 17:04:56 +01:00
Makefile.am libctf: installable libctf as a shared library 2019-10-03 17:04:56 +01:00
Makefile.in libctf: installable libctf as a shared library 2019-10-03 17:04:56 +01:00
swap.h libctf: fix a number of build problems found on Solaris and NetBSD 2019-05-31 11:10:51 +02:00