]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
loader/efi/linux: Correctly terminate load_options member
authorFrediano Ziglio <frediano.ziglio@cloud.com>
Wed, 25 Jun 2025 13:42:43 +0000 (14:42 +0100)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 26 Jun 2025 16:05:08 +0000 (18:05 +0200)
If a simple string for arguments are passed it should be NUL terminated.
This is true for other code but not for "linux" command.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/loader/efi/linux.c

index 5a2b7b5a15bd48a9919d65cebb3afe0e2ec74f8b..7ca80635c31e3238c13032fd2994861e83c3af1b 100644 (file)
@@ -233,6 +233,8 @@ grub_arch_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args)
 
   len = grub_utf8_to_utf16 (loaded_image->load_options, len,
                            (grub_uint8_t *) args, args_len, NULL);
+  /* NUL terminate. */
+  ((grub_efi_char16_t *) loaded_image->load_options)[len++] = 0;
   loaded_image->load_options_size = len * sizeof (grub_efi_char16_t);
 
   grub_dprintf ("linux", "starting image %p\n", image_handle);