Skip to content

uefi: process: Fix args #136186

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 1 commit into from
Jan 29, 2025
Merged
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
7 changes: 3 additions & 4 deletions library/std/src/sys/pal/uefi/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ mod uefi_command_internal {
helpers::open_protocol(self.handle, loaded_image::PROTOCOL_GUID).unwrap();

let len = args.len();
let args_size: u32 = crate::mem::size_of_val(&args).try_into().unwrap();
let args_size: u32 = (len * crate::mem::size_of::<u16>()).try_into().unwrap();
let ptr = Box::into_raw(args).as_mut_ptr();

unsafe {
Expand Down Expand Up @@ -706,9 +706,10 @@ mod uefi_command_internal {
res.push(QUOTE);
res.extend(prog.encode_wide());
res.push(QUOTE);
res.push(SPACE);

for arg in args {
res.push(SPACE);

// Wrap the argument in quotes to be treat as single arg
res.push(QUOTE);
for c in arg.encode_wide() {
Expand All @@ -719,8 +720,6 @@ mod uefi_command_internal {
res.push(c);
}
res.push(QUOTE);

res.push(SPACE);
}

res.into_boxed_slice()
Expand Down
Loading