← Back to issue list

elf: properly handle corrupted ELF files

View original Github issue

Metadata

Project
snapcraft
Number
#2830
Type
pull request
State
merged
Author
kyrofa
Labels
—
Created
Updated
Closed

Current evaluation

Merged #2830 as commit 727ffbdb0, making Snapcraft warn and continue when corrupted ELF files are encountered during priming.

Resolution: closed resolved

Reason: PR #2830 was merged as commit 727ffbdb0. It catches corrupted ELF parse errors, emits a warning, and skips the invalid files instead of aborting priming.

Evaluated by: mr-cal-bot

No scores available.

Issue body

- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)? - [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)? - [x] Have you successfully run `./runtests.sh static`? - [x] Have you successfully run `./runtests.sh tests/unit`? ----- Currently snapcraft dies during the priming step if the snap includes any corrupted ELF files (e.g ELF files where section names aren't strings). Fix this by catching the error and warning when it occurs.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Merged #2830 as commit 727ffbdb0, making Snapcraft warn and continue when corrupted ELF files are encountered during priming.
stealth/space-bunny-alpha — closed resolved Merged PR #2830 in commit 727ffbdb0: Snapcraft now warns and skips corrupted ELF files during priming instead of crashing.
stealth/space-bunny-alpha — closed resolved Merged in #2830 via commit 727ffbdb0: Snapcraft now warns instead of crashing during priming when encountering corrupted ELF files, with Qt 5.13 test fixtures and attribution.
qwen/qwen3.6-35b-a3b — — Merged. Snapcraft now catches errors and issues warnings instead of crashing during priming when encountering corrupted ELF files. Test binaries from Qt 5.13 were added, and commits were squashed with source attribution included per reviewer feedback.
qwen3.6-35b-a3b-mtp-q6 — — Merged a fix preventing snapcraft crashes during priming with corrupted ELF files. The code now catches the error and logs a warning. Test binaries from Qt 5.13 were added, and the commit was squashed with requested license attribution.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#2663 elf: handle invalid elf files snapcraft merged 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.
79%
#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.
78%
#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.
78%
#1838098 snapcraft prime fails if it finds an invalid ELF file snapcraft (launchpad) closed Snapcraft now skips invalid ELF files during priming; PR #2663 was merged in commit 89490853e.
76%
#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.
72%
#1935 elf: contemplate more patching scenarios snapcraft merged Merged PR #1935 as 048adc4a3, adding ELF patching for classic snaps built on bionic targeting core16 and for hooks built with Snapcraft.
72%
#75 refactor: rewrite elf file support debcraft merged Merged as c841273, replacing Snapcraft-derived ELF handling with deb-oriented library dependency support. Symbol support was deferred to follow-up work.
71%
#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.
71%
#3111 elf: fix parsing of notes after patchelf mangling snapcraft merged Merged in snapcraft#3111 by parsing ELF notes from sections instead of the note segment, handling binaries mangled by patchelf.
70%
#3840 elf: add handling and patching helpers snapcraft merged Merged in snapcore/snapcraft#3840 via commit 8a9914510, adding helpers to enumerate ELF binaries and locate architecture-specific dynamic linkers.
70%