diff options
| author | historia <[not public]> | 2026-10-05 17:05:14 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-10-05 17:05:14 -0400 |
| commit | e42952469dadfb3535633c66c881050ac128703c (patch) | |
| tree | a78f7396b72cdbd6fa4f6c454c830f40cf2ad0cb /internal/game/cmd_walk.go | |
| parent | 90ad8c0c33b519d5830c69d4128bdc984b5e9de8 (diff) | |
| download | thehouseoficarus-e42952469dadfb3535633c66c881050ac128703c.tar.gz | |
fix: gather verbs, walk oom, admin path bypass, roulette refund
Diffstat (limited to 'internal/game/cmd_walk.go')
| -rw-r--r-- | internal/game/cmd_walk.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/internal/game/cmd_walk.go b/internal/game/cmd_walk.go index 101c0fe..c9e7c0a 100644 --- a/internal/game/cmd_walk.go +++ b/internal/game/cmd_walk.go @@ -42,16 +42,28 @@ func (g *Game) doWalk(sess *net.Session, args []string) { func parseWalkDirections(input string) ([]string, error) { var dirs []string + total := 0 + // maxWalkSteps bounds the slice before it is allocated. Agility caps a + // real walk well below this; the limit exists only so a hostile count + // like "walk 999999999n" cannot allocate gigabytes on the owner goroutine. + const maxWalkSteps = 1000 i := 0 for i < len(input) { num := 0 for i < len(input) && input[i] >= '0' && input[i] <= '9' { num = num*10 + int(input[i]-'0') + if num > maxWalkSteps { + return nil, fmt.Errorf("too many steps at once (limit %d)", maxWalkSteps) + } i++ } if num == 0 { num = 1 } + total += num + if total > maxWalkSteps { + return nil, fmt.Errorf("too many steps at once (limit %d)", maxWalkSteps) + } if i >= len(input) { return nil, fmt.Errorf("unexpected end of directions") } |
