Skip to content

Add null terminator at the end of entry data#230

Open
zundamo-ti wants to merge 1 commit into
rhboot:mainfrom
zundamo-ti:fix/null-terminator
Open

Add null terminator at the end of entry data#230
zundamo-ti wants to merge 1 commit into
rhboot:mainfrom
zundamo-ti:fix/null-terminator

Conversation

@zundamo-ti
Copy link
Copy Markdown

Fix: add UCS-2 null terminator to --unicode optional data

Fixes #229

When --unicode is used, the optional data in the EFI load option is not null-terminated. This causes shim's split_load_options() to fail to extract the second-stage loader path, as it requires a space or null delimiter to identify the end of the path string.

Changes

In make_var():

  • Allocate 2 extra bytes when --unicode is set
  • Write UCS-2 null terminator at the end of the load option data before calling efi_set_variable()

Testing

Tested on Azure CVM (SEV-SNP) with Ubuntu 24.04 and shim + UKI boot chain.

Before fix:

  • efibootmgr --create --unicode produces optional data without null terminator
  • Boot entry fails, falls back to next entry in BootOrder

After fix:

  • Optional data correctly ends with 00 00
  • Boot entry matches byte-for-byte with firmware-created entries
  • Boot succeeds from the new entry

Signed-off-by: zundamo-ti <ykato1729@gmail.com>
@zundamo-ti zundamo-ti force-pushed the fix/null-terminator branch from 14bb6f6 to 8ead2fc Compare April 10, 2026 01:35
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.

--unicode optional data missing UCS-2 null terminator

1 participant