szn

Bug 354 — Remote panic: SGR colour params @intCast truncation

354. \x1b[38;5;999m kills the whole server

File: src/screen.zig:1306,1316,1332,1342,1358,1362 (reached from src/input.zig:743-759) Severity: CRITICAL Status: ✅ FIXED

Problem

Any pane output containing an out-of-range SGR colour parameter crashes szn in Debug/ReleaseSafe (“integer does not fit in destination type” — empirically confirmed with Zig 0.16.0). ReleaseFast silently wraps to a wrong palette slot.

Root Cause

The CSI param parser deliberately saturates values to maxInt(u32) (bug #99, input.zig:274) — but setSgr then did:

const idx = params[i];
i += 1;
self.cur_cell.fg = Colour.fromIndexed(@intCast(idx));   // idx: u32 → u8

at the indexed-colour and RGB parameter sites (38;5 / 48;5 / 38;2 / 48;2). The range-prong sites (30–37, 40–47, 90–97, 100–107) were provably safe.

Fix (applied)

Test: setSgr out-of-range colour params do not panic — bug #354 (maxInt index, 300/999 channels, wrap + ignore semantics asserted).