mirror of
https://github.com/JakeHillion/drgn.git
synced 2024-12-23 17:53:07 +00:00
libdrgn: dwarf_index: move .debug_str null-termination check
Check it right after we read the section instead of when updating the index.
This commit is contained in:
parent
9f9bec4762
commit
d423361d8a
@ -296,6 +296,7 @@ static struct drgn_error *read_sections(struct drgn_dwarf_index_file *file)
|
||||
Elf_Scn *scn = NULL;
|
||||
size_t section_index[DRGN_DWARF_INDEX_NUM_SECTIONS] = {};
|
||||
size_t i;
|
||||
Elf_Data *debug_str;
|
||||
|
||||
ehdr = gelf_getehdr(file->elf, &ehdr_mem);
|
||||
if (!ehdr)
|
||||
@ -345,6 +346,13 @@ static struct drgn_error *read_sections(struct drgn_dwarf_index_file *file)
|
||||
}
|
||||
}
|
||||
|
||||
debug_str = file->sections[SECTION_DEBUG_STR];
|
||||
if (debug_str->d_size == 0 ||
|
||||
((char *)debug_str->d_buf)[debug_str->d_size - 1] != '\0') {
|
||||
return drgn_error_create(DRGN_ERROR_DWARF_FORMAT,
|
||||
".debug_str is not null terminated");
|
||||
}
|
||||
|
||||
if (ehdr->e_type != ET_REL)
|
||||
return NULL;
|
||||
|
||||
@ -1638,16 +1646,6 @@ struct drgn_error *drgn_dwarf_index_update(struct drgn_dwarf_index *dindex)
|
||||
|
||||
file = first;
|
||||
do {
|
||||
Elf_Data *debug_str;
|
||||
|
||||
debug_str = file->sections[SECTION_DEBUG_STR];
|
||||
if (debug_str->d_size == 0 ||
|
||||
((char *)debug_str->d_buf)[debug_str->d_size - 1] != '\0') {
|
||||
err = drgn_error_create(DRGN_ERROR_DWARF_FORMAT,
|
||||
".debug_str is not null terminated");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((err = read_cus(file, &cus, &num_cus, &cus_capacity)))
|
||||
goto out;
|
||||
file = file->next;
|
||||
|
Loading…
Reference in New Issue
Block a user