Skip to content

uefi runtime: Increase default size of name buffer #1579

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

Merged
merged 4 commits into from
Mar 21, 2025
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
2 changes: 2 additions & 0 deletions uefi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 12 additions & 7 deletions uefi/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
Expand Down Expand Up @@ -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()),
Expand Down