mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-23 23:59:22 +00:00
script/execute: Don't crash on a "for" loop with no items
The following crashes the parser: for x in; do 0 done This is because grub_script_arglist_to_argv() doesn't consider the possibility that arglist is NULL. Catch that explicitly. This avoids a NULL pointer dereference. Signed-off-by: Daniel Axtens <dja@axtens.net> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
1 parent
2a330dba93
commit
0a05f88e2b
1 file changed
+3
@@ -624,6 +624,9 @@ grub_script_arglist_to_argv (struct grub_script_arglist *arglist,
|
|||||||
struct grub_script_arg *arg = 0;
|
struct grub_script_arg *arg = 0;
|
||||||
struct grub_script_argv result = { 0, 0, 0 };
|
struct grub_script_argv result = { 0, 0, 0 };
|
||||||
|
|
||||||
|
if (arglist == NULL)
|
||||||
|
return 1;
|
||||||
|
|
||||||
for (; arglist && arglist->arg; arglist = arglist->next)
|
for (; arglist && arglist->arg; arglist = arglist->next)
|
||||||
{
|
{
|
||||||
if (grub_script_argv_next (&result))
|
if (grub_script_argv_next (&result))
|
||||||
|
|||||||
Reference in new issue
Block a user