elf: handle invalid elf files
Metadata
Current evaluation
PR #2663 merged as commit 89490853e: snapcraft/elf/elf_utils.py now catches elftools ELFError (and CorruptedElfFile) during dependency scanning and silently skips invalid ELF files, with a regression test for LP #1838098.
Resolution: closed resolved
Reason: Maintainer Chris Patterson's PR #2663 was approved and merged into master as commit 89490853e, wrapping ElfFile construction in try/except ELFError in snapcraft/elf/elf_utils.py so malformed ELF files are ignored during dependency analysis. The fix remains in the current code (also catching errors.CorruptedElfFile with an emitted message), confirming the merge landed.
Evaluated by: mr-cal-bot
Issue body
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | PR #2663 merged as commit 89490853e: snapcraft/elf/elf_utils.py now catches elftools ELFError (and CorruptedElfFile) during dependency scanning and silently skips invalid ELF files, with a regression test for LP #1838098. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #2663 (commit 89490853e) by cjp256: snapcraft/elf/elf_utils.py now catches elftools ELFError and silently skips invalid ELF files instead of crashing, plus a regression test for LP #1838098. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #2663 as commit 89490853e: invalid ELF files are skipped after catching elftools exceptions, with a regression test for LP #1838098. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged changes to handle invalid ELF files by catching elftools exceptions and silently ignoring them. Includes a regression test, passed CI, and achieved 100% diff coverage. Resolves LP #1838098. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged. Catches elftools exceptions for invalid ELF files and silently ignores them. Includes a reproducing test case and references LP #1838098. Achieved 100% diff coverage. |
Update history
No update history recorded yet.
Related work
-
Related To:
snapcore/snapcraft#3514
(confidence 30%)
Later ELF work (elf: add fallback methods to detect library dependencies) touches the same elf_utils module, but did not resolve this item.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #2929 elf: fixes for corrupt shared objects | snapcraft | merged | Merged PR snapcore/snapcraft#2929 (commit 051f24e07, Feb 2020) catching elftools ConstructErrors as CorruptedElfFileError and skipping corrupt shared objects during library crawling. | |
| #2830 elf: properly handle corrupted ELF files | snapcraft | merged | Merged #2830 as commit 727ffbdb0, making Snapcraft warn and continue when corrupted ELF files are encountered during priming. | |
| #3839 elf: add elf file handler class | snapcraft | merged | PR #3839 was merged into main as commit 6830dc69c, porting the Snapcraft 6.x ElfFile handler into snapcraft/elf/_elf_file.py with helpers, ELF errors, and unit tests (CRAFT-1192). | |
| #2746 elf: handle missing dependencies not found on system | snapcraft | merged | Merged PR #2746 via ed3f32aa3: ELF scanning now retains unresolved libraries, falls back to sonames, parses ldd output reliably, and tests missing-library cases. | |
| #1913 elf: pyelftools to parse ELF files rather than readelf | snapcraft | merged | Merged PR #1913 (commit 9e4e88629): snapcraft.internal.elf.ElfFile now parses ELF files with pyelftools instead of shelling out to readelf, handling weak refs outside DT_NEEDED; cut test build times roughly in half. | |
| #3841 elf: add elf file patcher | snapcraft | merged | Merged PR #3841 in commit e03a971b3, adding a patchelf-based ELF file patcher ported from Snapcraft 6.x for CRAFT-1191. | |
| #1843 elf: warn if primed files will not work with the base's linker | snapcraft | merged | Merged PR #1843 (commit 42023dfaa) added ELF parsing of primed files in snapcraft/internal/elf.py, warning when a file's required glibc version is incompatible with the base's linker. Closes issue #1667. | |
| #2081 elf: patch everything instead of a subset of elf files | snapcraft | merged | Merged PR #2081 restored Snapcraft 2.39 behavior by patching every ELF file; commit 77770452b partially reverted 64f78f762a05. |