diff --git a/ChangeLog b/ChangeLog index db8915475..c0ceb3f46 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2001-02-02 OKUJI Yoshinori + + * stage2/builtins.c (savedefault_func) + [!SUPPORT_DISKLESS && !GRUB_UTIL]: Check if the stage2 is + STAGE2_ID_STAGE2. Suggested by Jochen Hoenicke. + + * stage2/stage2.c (cmain): If DEFAULT_ENTRY is out of entries, + reset DEFAULT_ENTRY to zero. + 2001-02-02 OKUJI Yoshinori Make savedefault workable even with Stage 1.5. Reported by diff --git a/stage2/builtins.c b/stage2/builtins.c index d6a102d16..e7f0fbebb 100644 --- a/stage2/builtins.c +++ b/stage2/builtins.c @@ -3080,7 +3080,14 @@ savedefault_func (char *arg, int flags) return 1; } - entryno_ptr = (int *) ((char *) buffer + STAGE2_SAVED_ENTRYNO); + /* Sanity check. */ + if (buffer[STAGE2_STAGE2_ID] != STAGE2_ID_STAGE2) + { + errnum = ERR_BAD_VERSION; + return 1; + } + + entryno_ptr = (int *) (buffer + STAGE2_SAVED_ENTRYNO); /* Check if the saved entry number differs from current entry number. */ if (*entryno_ptr != current_entryno) diff --git a/stage2/stage2.c b/stage2/stage2.c index c8d3f44dc..cf6496325 100644 --- a/stage2/stage2.c +++ b/stage2/stage2.c @@ -957,6 +957,11 @@ cmain (void) grub_memmove (config_entries + config_len, menu_entries, menu_len); menu_entries = config_entries + config_len; + /* Check if the default entry is present. Otherwise reset + DEFAULT_ENTRY. */ + if (default_entry >= num_entries) + default_entry = 0; + if (is_preset) close_preset_menu (); else