]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
util/grub-mkrescue: Check existence of option arguments
authorThomas Schmitt <scdbackup@gmx.net>
Mon, 17 Jun 2024 19:03:00 +0000 (21:03 +0200)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 20 Jun 2024 17:31:35 +0000 (19:31 +0200)
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 <scdbackup@gmx.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
util/grub-mkrescue.c

index abcc1c2f5e5f8861d22dbe87e2899de4354e5ab2..6dc71a8a162872cdb9d20a124a19915f752fd9ef 100644 (file)
@@ -477,6 +477,8 @@ main (int argc, char *argv[])
     for (i = 1; i < argc; i++)
       {
        if (strcmp (argv[i], "-output") == 0) {
+         if (i + 1 >= argc)
+           grub_util_error ("%s -- '%s'", _("option requires an argument"), argv[i]);
          argp_argv[argp_argc++] = (char *) "--output";
          i++;
          argp_argv[argp_argc++] = argv[i];
@@ -485,6 +487,8 @@ main (int argc, char *argv[])
        switch (args_to_eat (argv[i]))
          {
          case 2:
+           if (i + 1 >= argc)
+             grub_util_error ("%s -- '%s'", _("option requires an argument"), argv[i]);
            argp_argv[argp_argc++] = argv[i++];
            /* Fallthrough  */
          case 1: