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 panic when trying to read smbios_entry_point (64) table #92

Merged
merged 1 commit into from
Mar 21, 2022

Conversation

mulark
Copy link
Collaborator

@mulark mulark commented Mar 20, 2022

No description provided.

Copy link
Owner

@jrgerber jrgerber left a comment

Choose a reason for hiding this comment

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

Wow, another nice catch. Do you know what system(s) use the 64 bit entry? Apparently none that are being tested in GitHub right now.

@jrgerber jrgerber merged commit 2e993f6 into jrgerber:main Mar 21, 2022
@mulark
Copy link
Collaborator Author

mulark commented Mar 21, 2022

Not sure. This was only exposed when I was trying to run dmidecode-rs, specifically in this snippet

    match SMBiosEntryPoint64::try_load_from_file(entry_path) {
        Ok(entry_point) => {
            version = SMBiosVersion {
                major: entry_point.major_version(),
                minor: entry_point.minor_version(),
                revision: entry_point.docrev(),
            };

            writeln!(
                &mut output,
                "SMBIOS {}.{}.{} present.",
                entry_point.major_version(),
                entry_point.minor_version(),
                entry_point.docrev()
            )
            .unwrap();

            writeln!(
                &mut output,
                "Occupying {} bytes maximum.",
                entry_point.structure_table_maximum_size()
            )
            .unwrap();

            writeln!(
                &mut output,
                "Table at: {:#010X}.",
                entry_point.structure_table_address()
            )
            .unwrap();
        }

My smbios_entry_point file

sudo hexdump -C /sys/firmware/dmi/tables/smbios_entry_point 
00000000  5f 53 4d 33 5f 2d 18 03  02 00 01 00 20 09 00 00  |_SM3_-...... ...|
00000010  60 8d 0e 00 00 00 00 00                           |`.......|
00000018

We could consider making try_load_from_file parse preemptively and return an error rather than doing the parsing when the method is called, although that would be a decently sized refactoring.

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