Skip to content

Commit 4804ba0

Browse files
martinezjaviervathpela
authored andcommitted
fallback: fix fallback not passing arguments of the first boot option
The buffer used to read the data in the CSV is declared as a stack variable in the try_boot_csv() function, but a pointer to the arguments field of the first boot option is stored in the global first_new_option_args variable. Later, when is used set the arguments to boot the first entry, the variable points to memory that no longer exists. This leads to booting an entry with garbage as arguments instead of the correct value. Reported-by: Alexander Larsson <alexl@redhat.com> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
1 parent 4e51340 commit 4804ba0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fallback.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ add_boot_option(EFI_DEVICE_PATH *hddp, EFI_DEVICE_PATH *fulldp,
248248

249249
if (!first_new_option) {
250250
first_new_option = DuplicateDevicePath(fulldp);
251-
first_new_option_args = arguments;
251+
first_new_option_args = StrDuplicate(arguments);
252252
first_new_option_size = StrLen(arguments) * sizeof (CHAR16);
253253
}
254254

@@ -482,7 +482,7 @@ find_boot_option(EFI_DEVICE_PATH *dp, EFI_DEVICE_PATH *fulldp,
482482
/* at this point, we have duplicate data. */
483483
if (!first_new_option) {
484484
first_new_option = DuplicateDevicePath(fulldp);
485-
first_new_option_args = arguments;
485+
first_new_option_args = StrDuplicate(arguments);
486486
first_new_option_size = StrLen(arguments) * sizeof (CHAR16);
487487
}
488488

0 commit comments

Comments
 (0)