eliben / pyelftools

Parsing ELF and DWARF in Python
Other
1.99k stars 507 forks source link

Fix crash in readelf.py if a symbol doesn't define st_shndx #566

Open berolinux opened 1 month ago

berolinux commented 1 month ago

symbol['st_shndx'] can take a value of 'SHN_UNDEF' -- causing a crash in readelf.py when dumping the symbol table since that non-numeric value can't be compared to self.elffile.num_sections().

Add a check before assuming st_shndx is numeric.

sevaa commented 1 month ago

I'd do a plain comparison to the string literal 'SHN_UNDEF'. But no pressure :)