Skip to contentSkip to conversation

commands/test: Fix error in recursion depth calculation

PATCH In review Daniel Kiper via Grub-devel 1 participant 1 message Nov 18, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/8 commands/test: Fix error in recursion depth calculation

From: Thomas Frauendorfer | Miray Software <[email protected]>

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)
---
 grub-core/commands/test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/commands/test.c +1 -1
index b585c3d70..ee47ab264 100644
@@ -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;
 	    }
 
Signature · 7 lines
2.11.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel