Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: special elf program header with zero p_filesz #78

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fix ELF firmware parsing error, #77

## [0.1.0] - 2024-11-11

### Added
Expand Down
5 changes: 5 additions & 0 deletions src/firmware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ pub fn read_elf(elf_data: &[u8]) -> Result<Firmware> {

let flags = segment.p_flags(endian);

// The number of bytes in the file image of the segment, which can be zero.
if segment.p_filesz(endian) == 0 {
// skip empty segment
continue;
}
let segment_data = segment
.data(endian, elf_data)
.map_err(|_| anyhow::format_err!("Failed to access data for an ELF segment."))?;
Expand Down
Loading