From 4804ba077381dcd0288d98e3d08bc87ee77afad1 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 9 Nov 2021 16:39:37 +0100 Subject: 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 Signed-off-by: Javier Martinez Canillas --- fallback.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fallback.c b/fallback.c index d2c73acd..5da867dd 100644 --- a/fallback.c +++ b/fallback.c @@ -248,7 +248,7 @@ add_boot_option(EFI_DEVICE_PATH *hddp, EFI_DEVICE_PATH *fulldp, if (!first_new_option) { first_new_option = DuplicateDevicePath(fulldp); - first_new_option_args = arguments; + first_new_option_args = StrDuplicate(arguments); first_new_option_size = StrLen(arguments) * sizeof (CHAR16); } @@ -482,7 +482,7 @@ find_boot_option(EFI_DEVICE_PATH *dp, EFI_DEVICE_PATH *fulldp, /* at this point, we have duplicate data. */ if (!first_new_option) { first_new_option = DuplicateDevicePath(fulldp); - first_new_option_args = arguments; + first_new_option_args = StrDuplicate(arguments); first_new_option_size = StrLen(arguments) * sizeof (CHAR16); } -- cgit v1.2.3