Skip to content

Fix SMBIOS parsing on big-endian architecture#56

Merged
jcreekmore merged 1 commit intojcreekmore:masterfrom
nadzyah:fix-big-endian-arch
Mar 25, 2026
Merged

Fix SMBIOS parsing on big-endian architecture#56
jcreekmore merged 1 commit intojcreekmore:masterfrom
nadzyah:fix-big-endian-arch

Conversation

@nadzyah
Copy link
Copy Markdown
Contributor

@nadzyah nadzyah commented Mar 23, 2026

I'm maintaining this crate in Debian. The test suite currently fails there on s390x because the packed struct deserialisation uses ptr::read, which reads multi-byte fields in native byte order, but SMBIOS defines all fields as little-endian.

I know s390x is an unusual target for an SMBIOS library. However, I've noticed that the codebase already uses from_le_bytes via the TryFromBytes trait in RawStructure::get(), showing the intent was always to parse SMBIOS fields as little-endian. The packed struct path is simply an oversight that went unnoticed because the test suite only runs on x86.

The fix applies from_le() to all u16/u32/u64 fields read from packed structs

Copy link
Copy Markdown
Owner

@jcreekmore jcreekmore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine, but is failing the format checks. Also, I found another issue with the tests related to #55, so I fixed that up in master. If you can fix the formatting and rebase on top of master, I will merge and cut a patch release.

SMBIOS defines all multi-byte fields as little-endian, but the packed
struct deserialization used ptr::read which reads in native byte
order. Apply from_le() to all u16/u32/u64 fields read from packed
structs and via the read_bytes helper
@nadzyah nadzyah force-pushed the fix-big-endian-arch branch from 12c06cb to fb3147c Compare March 25, 2026 07:35
@jcreekmore jcreekmore merged commit 573ed14 into jcreekmore:master Mar 25, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants