eliben / pyelftools

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

Fix iter_notes to handle >4 byte segment alignment #537

Closed martijnthe closed 7 months ago

martijnthe commented 7 months ago

An ELF note's name and data are always 4-byte aligned. However, when the containing segment has a larger alignment requirement, additional padding gets added after the last note. This was not being handled correctly by the iter_notes method. This PR fixes the problem by ensuring there is enough data left to at least parse a note header.

I did not find another way to determine the "real size" of a note segment.

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

eliben commented 7 months ago

@sevaa

sevaa commented 7 months ago

Again, no objections, the code looks sensible, the business case is alien to me, but who knows what do linkers out there emit.

martijnthe commented 7 months ago

Thanks @eliben for merging my PRs. Could you publish a new release to pypi? Thank you 🙏