From 67e01aab85607b9e601185c7d62dff576af3bb43 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Fri, 18 Sep 2026 15:42:23 -0400 Subject: fix: close map OOM, admin traversal, transport safespot, room rekey, and legacy payout recovery --- internal/game/map_bounds_regression_test.go | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 internal/game/map_bounds_regression_test.go (limited to 'internal/game/map_bounds_regression_test.go') 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) + } +} -- cgit v1.2.3