Account for string offsets table header size

Section 7.26 of the DWARF 5 spec describes a header of
either 8 or 16 bytes before the offsets begin.

Bug: b/187205051
Change-Id: I1ba01008dcd7a533f59d3865762ca09b9d43032b
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3016609
Reviewed-by: Sterling Augustine <saugustine@google.com>
This commit is contained in:
Joshua Peraza 2021-07-08 15:13:33 -07:00
parent 68735f74e7
commit 415b54ab8c

View file

@ -456,8 +456,14 @@ uint64_t CompilationUnit::Start() {
void CompilationUnit::ProcessFormStringIndex(
uint64_t dieoffset, enum DwarfAttribute attr, enum DwarfForm form,
uint64_t str_index) {
const size_t kStringOffsetsTableHeaderSize =
reader_->OffsetSize() == 8 ? 16 : 8;
const uint8_t* str_offsets_table_after_header = str_offsets_base_ ?
str_offsets_buffer_ + str_offsets_base_ :
str_offsets_buffer_ + kStringOffsetsTableHeaderSize;
const uint8_t* offset_ptr =
str_offsets_buffer_ + str_offsets_base_ + str_index * reader_->OffsetSize();
str_offsets_table_after_header + str_index * reader_->OffsetSize();
const uint64_t offset = reader_->ReadOffset(offset_ptr);
if (offset >= string_buffer_length_) {
return;