binutils-gdb/libctf
Nick Alcock cf02c44dfd libctf: fix ctf_open endianness problems with raw CTF files
ctf_open (or, rather, ctf_fdopen, which underlies it) has several
endianness problems, even though it was written after the
endian-swapping code was implemented, so should have been endian-aware.

Even though the comment right above the relevant check says that it wil
check for CTF magic in any endianness, it only checks in the native
endianness, so opening raw LE CTF files on BE, or vice-versa, will fail.
It also checks the CTF version by hand, without ever endianness-swapping
the header, so that too will fail, and is entirely redundant because
ctf_simple_open does the job properly in any case.  We have a similar
problem in the next if block, which checks for raw CTF archives: we are
checking in the native endianness while we should be doing a le64toh()
on it to check in little-endian form only: so opening CTF archives
created on the local machine will fail if the local machine is
big-endian.

Adding insult to injury, if ctf_simple_open then fails, we go on and try
to turn it into a single-element CTF archive regardless, throwing the
error away.  Since this involves dereferencing null pointers it is not
likely to work very well.

libctf/
	* ctf-open-bfd.c: Add swap.h and ctf-endian.h.
	(ctf_fdopen): Check for endian-swapped raw CTF magic, and
	little-endian CTF archive magic.  Do not check the CTF version:
	ctf_simple_open does that in endian-safe ways.  Do not dereference
	null pointers on open failure.
2019-06-21 13:04:02 +01:00
..
ChangeLog libctf: fix ctf_open endianness problems with raw CTF files 2019-06-21 13:04:02 +01:00
Makefile.am libctf: look for BSD versus GNU qsort_r signatures 2019-06-04 17:05:08 +01:00
Makefile.in libctf: look for BSD versus GNU qsort_r signatures 2019-06-04 17:05:08 +01:00
aclocal.m4 libctf: fix a number of build problems found on Solaris and NetBSD 2019-05-31 11:10:51 +02:00
config.h.in libctf: work on platforms without O_CLOEXEC. 2019-06-04 17:05:08 +01:00
configure Regenerate with approved autotools version 2019-06-14 10:30:35 +09:30
configure.ac libctf: work on platforms without O_CLOEXEC. 2019-06-04 17:05:08 +01:00
ctf-archive.c libctf: mark various args as unused in the !HAVE_MMAP case 2019-06-07 13:46:38 +01:00
ctf-create.c libctf: drop mmap()-based CTF data allocator 2019-06-21 13:04:02 +01:00
ctf-decl.c libctf: core type lookup 2019-05-28 17:08:14 +01:00
ctf-decls.h libctf: avoid strndup 2019-06-07 13:46:39 +01:00
ctf-dump.c libctf: explicitly cast more size_t types used in printf()s 2019-06-07 13:46:38 +01:00
ctf-endian.h libctf: fix a number of build problems found on Solaris and NetBSD 2019-05-31 11:10:51 +02:00
ctf-error.c libctf: error handling 2019-05-28 17:07:24 +01:00
ctf-hash.c libctf: hashing 2019-05-28 17:07:29 +01:00
ctf-impl.h libctf: drop mmap()-based CTF data allocator 2019-06-21 13:04:02 +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-lookup.c libctf: avoid strndup 2019-06-07 13:46:39 +01:00
ctf-open-bfd.c libctf: fix ctf_open endianness problems with raw CTF files 2019-06-21 13:04:02 +01:00
ctf-open.c libctf: endianness fixes 2019-06-21 13:04:02 +01:00
ctf-qsort_r.c libctf: look for BSD versus GNU qsort_r signatures 2019-06-04 17:05:08 +01:00
ctf-subr.c libctf: drop mmap()-based CTF data allocator 2019-06-21 13:04:02 +01:00
ctf-types.c libctf: fix a number of build problems found on Solaris and NetBSD 2019-05-31 11:10:51 +02:00
ctf-util.c libctf: fix a number of build problems found on Solaris and NetBSD 2019-05-31 11:10:51 +02:00
elf.h
swap.h libctf: fix a number of build problems found on Solaris and NetBSD 2019-05-31 11:10:51 +02:00