binutils-gdb/libctf/testsuite
Nick Alcock 6ab5b6d0f3 libctf, lookup: fix bounds of pptrtab lookup
An off-by-one bug in the check for pptrtab lookup meant that we could
access the pptrtab past its bounds (*well* past its bounds),
particularly if we called ctf_lookup_by_name in a child dict with "*foo"
where "foo" is a type that exists in the parent but not the child and no
previous lookups by name have been carried out.  (Note that "*foo" is
not even a valid thing to call ctf_lookup_by_name with: foo * is.
Nonetheless, users sometimes do call ctf_lookup_by_name with invalid
content, and it should return ECTF_NOTYPE, not crash.)

ctf_pptrtab_len, as its name suggests (and as other tests of it in
ctf-lookup.c confirm), is one higher than the maximum valid permissible
index, so the comparison is wrong.

(Test added, which should fail pretty reliably in the presence of this
bug on any machine with 4KiB pages.)

libctf/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-lookup.c (ctf_lookup_by_name_internal): Fix pptrtab bounds.
	* testsuite/libctf-writable/pptrtab-writable-page-deep-lookup.*:
	New test.
2021-09-27 20:31:26 +01:00
..
config CC_FOR_TARGET et al 2021-09-03 16:26:09 +09:30
lib CC_FOR_TARGET et al 2021-09-03 16:26:09 +09:30
libctf-lookup libctf, testsuite: fix various warnings in tests 2021-09-27 20:31:26 +01:00
libctf-regression libctf, testsuite: fix various warnings in tests 2021-09-27 20:31:26 +01:00
libctf-writable libctf, lookup: fix bounds of pptrtab lookup 2021-09-27 20:31:26 +01:00