Skip to content

Commit c1a672a

Browse files
committed
fix(bootloader-interface): report the correct firmware revision
1 parent a2f017b commit c1a672a

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/integrations/bootloader_interface.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl BootloaderInterface {
8888
// Write the bytes into the data buffer.
8989
data.extend_from_slice(&encoded);
9090
// Add a null terminator to the end of the entry.
91-
data.push(0);
91+
data.extend_from_slice(&[0, 0]);
9292
}
9393
Self::VENDOR.set(
9494
"LoaderEntries",
@@ -117,12 +117,15 @@ impl BootloaderInterface {
117117

118118
/// Tell the system about the UEFI firmware we are running on.
119119
pub fn set_firmware_info() -> Result<()> {
120+
// Access the firmware revision.
121+
let revision = uefi::system::firmware_revision();
122+
120123
// Format the firmware information string into something human-readable.
121124
let firmware_info = format!(
122125
"{} {}.{:02}",
123126
uefi::system::firmware_vendor(),
124-
uefi::system::firmware_revision() >> 16,
125-
uefi::system::firmware_revision() & 0xFFFFF,
127+
revision >> 16,
128+
revision & 0xffff,
126129
);
127130
Self::VENDOR.set_cstr16(
128131
"LoaderFirmwareInfo",
@@ -131,7 +134,7 @@ impl BootloaderInterface {
131134
)?;
132135

133136
// Format the firmware revision into something human-readable.
134-
let firmware_type = format!("UEFI {:02}", uefi::system::firmware_revision());
137+
let firmware_type = format!("UEFI {}.{:02}", revision >> 16, revision & 0xffff);
135138
Self::VENDOR.set_cstr16(
136139
"LoaderFirmwareType",
137140
&firmware_type,

src/utils/variables.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl VariableController {
8989
.flat_map(|c| c.to_le_bytes())
9090
.collect::<Vec<u8>>();
9191
// Add a null terminator to the end of the value.
92-
encoded.push(0);
92+
encoded.extend_from_slice(&[0, 0]);
9393
self.set(key, &encoded, class)
9494
}
9595

0 commit comments

Comments
 (0)