From 08434926f5eda975808f66b45b3a828458d5ba7e Mon Sep 17 00:00:00 2001 From: JP Appel Date: Sat, 19 Jul 2025 01:08:54 -0400 Subject: Add limit to interperter stack size --- pkg/shell/interpreter.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'pkg/shell') diff --git a/pkg/shell/interpreter.go b/pkg/shell/interpreter.go index 6c1a89a..c222de0 100644 --- a/pkg/shell/interpreter.go +++ b/pkg/shell/interpreter.go @@ -17,6 +17,7 @@ import ( ) const COMMENT_STR = "#" +const STACK_LIMIT = 256 type keywords struct { commands []string @@ -177,6 +178,9 @@ out: for i := len(tokens) - 1; i >= 0; i-- { t := tokens[i] top := len(stack) - 1 + if top >= STACK_LIMIT { + return false, fmt.Errorf("Stack Limit of %d exceeded", STACK_LIMIT) + } switch t.Type { case ITOK_CMD_HELP: printHelp(w) -- cgit v1.2.3