improve the robustness of savedefault and default.
This commit is contained in:
parent
00865a8027
commit
dc1c0a6ccf
3 changed files with 22 additions and 1 deletions
|
@ -1,3 +1,12 @@
|
|||
2001-02-02 OKUJI Yoshinori <okuji@gnu.org>
|
||||
|
||||
* 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 <okuji@gnu.org>
|
||||
|
||||
Make savedefault workable even with Stage 1.5. Reported by
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue