eliben / pyelftools

Parsing ELF and DWARF in Python
Other
2.03k stars 512 forks source link

Fix buffer overrun in NT_GNU_PROPERTY_TYPE_0 parser #538

Closed martijnthe closed 9 months ago

martijnthe commented 9 months ago

The iter_notes method has code to parse NT_GNU_PROPERTY_TYPE_0 type notes. The contents of the note are interpreted as an array of elffile.structs.Elf_Props.

There was a bug where it would keep on parsing from the stream until the end of the segment or section. This is only correct if the note would be the last in the segment/section. In general, it should stop parsing until it reaches the end of the note's data buffer.

This PR fixes this bug.

Fixes: https://github.com/eliben/pyelftools/issues/534

eliben commented 9 months ago

@sevaa

sevaa commented 9 months ago

No objections. Compilers are a diverse bunch...

martijnthe commented 9 months ago

@eliben I've addressed your comment and resolved the conflicts with the other PR.