Fix iter_notes crash on GNU build-ID notes in core dumps - #665
Conversation
In an ET_CORE file type 3 decodes as NT_PRPSINFO, so a GNU build-ID note (type 3, name 'GNU') got parsed as a 124-byte prpsinfo struct and raised ELFParseError. Re-resolve GNU-named notes against the generic note enum so type 3 stays NT_GNU_BUILD_ID.
sevaa
left a comment
There was a problem hiding this comment.
Never had to deal with coredumps myself, but the logic looks sensible. We don't have a lot of coredumps in the corpus though, do we?
|
Yeah, just the three |
|
While the logic looks ok, the whole issue feels extremely niche to me. It would be nicer to see a more general solution here, as well as a couple of representative core files committed in that actual comparison tests could run on. |
|
I'll switch to the general version: resolve the type from For fixtures: what do you prefer? |
|
Generating a small real coredump is fine - but please include clear instructions on how to reproduce it (e.g. a simple C file, the gcc command to create the binary, and the execution steps). |
Core dumps can carry a GNU build-ID note (type 3, name
GNU). But in anET_COREfile type 3 meansNT_PRPSINFO, soiter_notes()reads the short build ID as a 124-byte prpsinfo struct and blows up withELFParseError. readelf handles the same file fine.Fix: if a note is named
GNUin a core file, resolve its type against the generic GNU enum instead. Only touches core files.Open question for you: the broader fix is to decode
n_typeas a raw int and pick the enum fromn_nameiniter_notes. More general, but it changes the shared struct, so I kept this contained. Your call.Test builds a tiny ET_CORE ELF with a build-ID note. Fails before, passes after. Suite green, ruff clean.
Closes #656.