diff --git a/uefi/CHANGELOG.md b/uefi/CHANGELOG.md index 8848c7abd..630462fb9 100644 --- a/uefi/CHANGELOG.md +++ b/uefi/CHANGELOG.md @@ -22,6 +22,8 @@ zero. The allocation is retried instead, and in all failure cases an error is returned rather than panicking. - The `Display` impl for `CStr8` now excludes the trailing null character. +- `VariableKeys` initializes with a larger name buffer to work around firmware + bugs on some devices. # uefi - 0.34.1 (2025-02-07) diff --git a/uefi/src/runtime.rs b/uefi/src/runtime.rs index a61dee296..2d2450265 100644 --- a/uefi/src/runtime.rs +++ b/uefi/src/runtime.rs @@ -16,8 +16,12 @@ use uefi_raw::table::boot::MemoryDescriptor; #[cfg(feature = "alloc")] use { - crate::mem::make_boxed, crate::CString16, crate::Guid, alloc::borrow::ToOwned, - alloc::boxed::Box, alloc::vec::Vec, + crate::mem::make_boxed, + crate::CString16, + crate::Guid, + alloc::borrow::ToOwned, + alloc::boxed::Box, + alloc::{vec, vec::Vec}, }; #[cfg(all(feature = "unstable", feature = "alloc"))] @@ -268,13 +272,14 @@ pub struct VariableKeys { #[cfg(feature = "alloc")] impl VariableKeys { fn new() -> Self { - // Create a the name buffer with a reasonable default capacity, and - // initialize it to an empty null-terminated string. - let mut name = Vec::with_capacity(32); - name.push(0); + // Create a name buffer with a large default size and zero + // initialize it. A Toshiba Satellite Pro R50-B-12P was found + // to not correctly update the VariableNameSize passed into + // GetNextVariableName and starting with a large buffer works + // around this issue. + let name = vec![0; 512]; Self { - // Give the name buffer a reasonable default capacity. name, // The initial vendor GUID is arbitrary. vendor: VariableVendor(Guid::default()),