libdw: check that DWARF strings are null-terminated
authorAleksei Vetrov <vvvvvv@google.com>
Tue, 14 Feb 2023 20:30:02 +0000 (20:30 +0000)
committerMark Wielaard <mark@klomp.org>
Thu, 16 Feb 2023 23:18:53 +0000 (00:18 +0100)
commitfda09f5f188fb173b2123815be71ca4647a8adfb
treefc66ad4c3abae0765528e7b7bbb622882d4e9182
parent73e212b0a778c6dbe84f79b7eb2647dea50ea16f
libdw: check that DWARF strings are null-terminated

It is expected from libdw to return strings that are null-terminated to
avoid overflowing ELF data.

* Add calculation of a safe prefix inside string sections, where any
  string will be null-terminated.

* Check if offset overflows the safe prefix in dwarf_formstring.

Signed-off-by: Aleksei Vetrov <vvvvvv@google.com>
libdw/dwarf_begin_elf.c
libdw/dwarf_formstring.c
libdw/libdwP.h