]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
commands/test: Fix error in recursion depth calculation
authorThomas Frauendorfer | Miray Software <tf@miray.de>
Fri, 9 May 2025 11:51:08 +0000 (13:51 +0200)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 18 Nov 2025 13:34:44 +0000 (14:34 +0100)
The commit c68b7d236 (commands/test: Stack overflow due to unlimited
recursion depth) added recursion depth tests to the test command. But in
the error case it decrements the pointer to the depth value instead of
the value itself. Fix it.

Fixes: c68b7d236 (commands/test: Stack overflow due to unlimited recursion depth)
Signed-off-by: Thomas Frauendorfer | Miray Software <tf@miray.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/commands/test.c

index b585c3d70316da69a7ef2b84862bbe3c7d80a8b3..ee47ab2641a6cda3ab5b166e45bf2f0cf07a3b05 100644 (file)
@@ -403,7 +403,7 @@ test_parse (char **args, int *argn, int argc, int *depth)
          if (++(*depth) > MAX_TEST_RECURSION_DEPTH)
            {
              grub_error (GRUB_ERR_OUT_OF_RANGE, N_("max recursion depth exceeded"));
-             depth--;
+             (*depth)--;
              return ctx.or || ctx.and;
            }