From e42952469dadfb3535633c66c881050ac128703c Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Mon, 5 Oct 2026 17:05:14 -0400 Subject: fix: gather verbs, walk oom, admin path bypass, roulette refund --- internal/game/cmd_walk.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'internal/game/cmd_walk.go') 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") } -- cgit v1.2.3