aboutsummaryrefslogtreecommitdiff
path: root/internal/game/map_bounds_regression_test.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-18 15:42:23 -0400
committerhistoria <[not public]>2026-09-18 15:42:23 -0400
commit67e01aab85607b9e601185c7d62dff576af3bb43 (patch)
tree059134b2434eba7c14aa9d89f48c5a475feb0312 /internal/game/map_bounds_regression_test.go
parent7eab582d8a8ee2af1a6baae7baf0696c7005de2e (diff)
downloadthehouseoficarus-67e01aab85607b9e601185c7d62dff576af3bb43.tar.gz
fix: close map OOM, admin traversal, transport safespot, room rekey, and legacy payout recovery
Diffstat (limited to 'internal/game/map_bounds_regression_test.go')
-rw-r--r--internal/game/map_bounds_regression_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/game/map_bounds_regression_test.go b/internal/game/map_bounds_regression_test.go
new file mode 100644
index 0000000..dd3423b
--- /dev/null
+++ b/internal/game/map_bounds_regression_test.go
@@ -0,0 +1,34 @@
+package game
+
+import (
+ "testing"
+
+ "thehouseoficarus/internal/player"
+)
+
+// TestMapDimensionsClamped: the player-settable map size drives a direct
+// mapHeight x mapWidth allocation in buildFullMap, so an unbounded option
+// value is a fatal out-of-memory kill reachable by any authenticated player
+// (and persisted in the account file, so it repeats on login). The clamp must
+// cap both dimensions while leaving ordinary values alone.
+func TestMapDimensionsClamped(t *testing.T) {
+ p := player.New("mapper")
+
+ p.Options = map[string]any{"map_width": 100000, "map_height": 100000}
+ w, h := mapDimensions(p)
+ if w != maxMapDimension || h != maxMapDimension {
+ t.Fatalf("huge map dimensions = (%d,%d), want (%d,%d)", w, h, maxMapDimension, maxMapDimension)
+ }
+
+ p.Options = map[string]any{"map_width": -5, "map_height": 0}
+ w, h = mapDimensions(p)
+ if w != 5 || h != 5 {
+ t.Fatalf("undersized map dimensions = (%d,%d), want (5,5)", w, h)
+ }
+
+ p.Options = map[string]any{"map_width": 30, "map_height": 20}
+ w, h = mapDimensions(p)
+ if w != 30 || h != 20 {
+ t.Fatalf("normal map dimensions = (%d,%d), want (30,20)", w, h)
+ }
+}