discover/grub2: Allow to separate the --id argument using a space char
[petitboot] / discover / grub2 / script.c
index c910bf8bc1a28bf86901459b11d7a99ad059bc35..8a9d91dac987c36680283f8b9c95cfdf6ac15fb5 100644 (file)
@@ -339,9 +339,16 @@ int statement_menuentry_execute(struct grub2_script *script,
         * implementation to get --id= working.
         */
        for (i = 1; i < st->argv->argc; ++i) {
-               if (strncmp("--id=", st->argv->argv[i], 5) == 0) {
-                       id = st->argv->argv[i] + 5;
-                       break;
+               if (strncmp("--id", st->argv->argv[i], strlen("--id")) == 0) {
+                       if (strlen(st->argv->argv[i]) > strlen("--id=")) {
+                               id = st->argv->argv[i] + strlen("--id=");
+                               break;
+                       }
+
+                       if (i + 1 < st->argv->argc) {
+                               id = st->argv->argv[i + 1];
+                               break;
+                       }
                }
        }
        if (st->argv->argc > 0)