szn

Bug 389 — IPC / tty hygiene cluster

389. Four small IPC/terminal-setup defects

Severity: LOW Status: ✅ FIXED

Fix (applied)

| Site | Change | |——|——–| | connect.zig | Client socket is cloexec’d via pty.setCloexec — no longer leaks into spawned children. | | message_reader.zig | packetType now returns ?MessageType via MessageType.fromByte instead of @enumFromInt on a closed enum; wire garbage yields null, not a panic. Tests updated + new null case. | | protocol.zig | Packet.make keeps header/body consistent by truncating the body to what a u32 length can describe, rather than fabricating a clamped length over an oversized slice. | | raw.zig | setRaw sets cflag.CSIZE = .CS8 and clears PARENB (cfmakeraw parity rules; CSIZE is an enum on every platform); restore and set use TCSANOW so exiting szn no longer discards pending output (was TCSA.FLUSH). Follow-up: the original CS8 = true bool form only compiled on non-Linux tc_cflag layouts — caught by ReleaseFast exe build, fixed portably. |

All existing suite green.

# Site Finding
a connect.zig:22 Client socket created without SOCK_CLOEXEC — unlike server/pty fds — so it leaks into anything the client spawns.
b message_reader.zig:93-95 packetType does @enumFromInt on a closed enum with a wire-controlled byte → checked panic if ever called. Currently unused in production (server uses fromByte); delete or return ?MessageType.
c protocol.zig:101-114 Packet.make clamps declared length to maxInt(u32) but keeps the full data slice; serialize would copy more body than the header declares. Unreachable today; should reject instead of fabricating.
d raw.zig:36-44 setRaw zeroes iflag/lflag/oflag but never forces CS8 / clears PARENB (cfmakeraw parity rules) — 7-bit or parity terminals mangle UTF-8 input. deinit restores with TCSA.FLUSH, discarding pending output.