diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index 5c1d2533d77..2766c8452f4 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -723,7 +723,7 @@ static int status_entries( printf("Default Boot Loader Entry:\n"); r = boot_entry_show( - config.entries + config.default_entry, + boot_config_default_entry(&config), /* show_as_default= */ false, /* show_as_selected= */ false, /* show_discovered= */ false); diff --git a/src/shared/bootspec.h b/src/shared/bootspec.h index 5c4b211ee4c..0f199d5ee90 100644 --- a/src/shared/bootspec.h +++ b/src/shared/bootspec.h @@ -56,6 +56,7 @@ typedef struct BootConfig { BootEntry *entries; size_t n_entries; + ssize_t default_entry; ssize_t selected_entry; @@ -86,10 +87,12 @@ static inline BootEntry* boot_config_default_entry(BootConfig *config) { if (config->default_entry < 0) return NULL; + assert((size_t) config->default_entry < config->n_entries); return config->entries + config->default_entry; } void boot_config_free(BootConfig *config); + int boot_entries_load_config(const char *esp_path, const char *xbootldr_path, BootConfig *config); int boot_entries_load_config_auto(const char *override_esp_path, const char *override_xbootldr_path, BootConfig *config); int boot_entries_augment_from_loader(BootConfig *config, char **list, bool only_auto);