create_minidebuginfo: Avoid overflow of ABS symbols.
Bug: 278156681
Change-Id: I441e73cf2c473202eb9f72dba7ab28722fee37ce
diff --git a/libelffile/elf/elf_debug_reader.h b/libelffile/elf/elf_debug_reader.h
index 6e01989..fc7ad56 100644
--- a/libelffile/elf/elf_debug_reader.h
+++ b/libelffile/elf/elf_debug_reader.h
@@ -127,7 +127,9 @@
CHECK_EQ(symtab->sh_entsize, sizeof(Elf_Sym));
size_t count = symtab->sh_size / sizeof(Elf_Sym);
for (const Elf_Sym& symbol : Read<Elf_Sym>(symtab->sh_offset, count)) {
- if (ELF_ST_TYPE(symbol.st_info) == STT_FUNC && §ions_[symbol.st_shndx] == text) {
+ if (ELF_ST_TYPE(symbol.st_info) == STT_FUNC &&
+ symbol.st_shndx < sections_.size() && // Ignore ABS section.
+ §ions_[symbol.st_shndx] == text) {
visit_sym(symbol, Read<char>(strtab->sh_offset + symbol.st_name));
}
}