diff options
| author | JP Appel <jeanpierre.appel01@gmail.com> | 2025-07-19 01:08:54 -0400 |
|---|---|---|
| committer | JP Appel <jeanpierre.appel01@gmail.com> | 2025-07-19 01:08:54 -0400 |
| commit | 08434926f5eda975808f66b45b3a828458d5ba7e (patch) | |
| tree | eb06f6a1d6baef042625734e0ed67dae2c1ff423 /pkg/shell/interpreter.go | |
| parent | ce7bb43b8e0910c812c8ab9299969679082507b9 (diff) | |
Add limit to interperter stack size
Diffstat (limited to 'pkg/shell/interpreter.go')
| -rw-r--r-- | pkg/shell/interpreter.go | 4 |
1 files changed, 4 insertions, 0 deletions
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) |
