Skip to contentSkip to conversation

extract_legacy_entries_source hoses system when menu.lst can't be opened

PATCH Seth Goldberg 1 participant 1 message Jan 28, 2012

lore
Share & tools
lore
#0 lore raw

Hi there,

In grub_cmd_legacy_source, if the menu.lst file cannot opened in
legacy_file(), grub_env_extractor_close() attempts to access memory at address 4, which could end up corrupting the entire menu.

The easy fix is to check if the first call to grub_env_get_menu() returns
NULL and bail out (after the grub_env_context_close() and grub_extractor_level--, of course), since there's no point trying to append menu entries to the prev menu (since there are none).

--S

grub-core/normal/context.c +1 -1
@@ -159,7 +159,7 @@
     }
   err = grub_env_context_close ();
 
-  if (source)
+  if (source && menu)
     {
       grub_menu_t menu2;
       menu2 = grub_env_get_menu ();