Skip to content

Commit b53ec06

Browse files
scdbackupDaniel Kiper
authored and
Daniel Kiper
committed
util/grub-mkrescue: Check existence of option arguments
As reported by Victoriia Egorova in bug 65880, grub-mkrescue does not verify that the expected argument of an option like -d or -k does really exist in argv. So, check the loop counter before incrementing it inside the loop which copies argv to argp_argv. Issue an error message similar to what older versions of grub-mkrescue did with a missing argument, e.g. 2.02. Fixes: https://savannah.gnu.org/bugs/index.php?65880 Signed-off-by: Thomas Schmitt <[email protected]> Reviewed-by: Daniel Kiper <[email protected]>
1 parent ab9fe80 commit b53ec06

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

util/grub-mkrescue.c

+4
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,8 @@ main (int argc, char *argv[])
477477
for (i = 1; i < argc; i++)
478478
{
479479
if (strcmp (argv[i], "-output") == 0) {
480+
if (i + 1 >= argc)
481+
grub_util_error ("%s -- '%s'", _("option requires an argument"), argv[i]);
480482
argp_argv[argp_argc++] = (char *) "--output";
481483
i++;
482484
argp_argv[argp_argc++] = argv[i];
@@ -485,6 +487,8 @@ main (int argc, char *argv[])
485487
switch (args_to_eat (argv[i]))
486488
{
487489
case 2:
490+
if (i + 1 >= argc)
491+
grub_util_error ("%s -- '%s'", _("option requires an argument"), argv[i]);
488492
argp_argv[argp_argc++] = argv[i++];
489493
/* Fallthrough */
490494
case 1:

0 commit comments

Comments
 (0)