aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_walk.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-10-05 17:05:14 -0400
committerhistoria <[not public]>2026-10-05 17:05:14 -0400
commite42952469dadfb3535633c66c881050ac128703c (patch)
treea78f7396b72cdbd6fa4f6c454c830f40cf2ad0cb /internal/game/cmd_walk.go
parent90ad8c0c33b519d5830c69d4128bdc984b5e9de8 (diff)
downloadthehouseoficarus-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.go12
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")
}