From 4640cef5f7237422b178122eea403858fcd560ea Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 23 Nov 2026 15:56:20 -0300 Subject: rows: a style is one the syntax has, or the write is refused: a pane rows line took a style number as any u4 (core/locations.zig parseRows, 1..15) where the render casts the style syntax bits into `Syn` (four kinds): `m 1 1 0 0 0 0 0 3:0+3=7 a.txt` written to a +Search pane rows, then any frame, panicked (`invalid enum value`, core/File.zig:2079 recolorSyntax) the session and every client that draws; now the decoder yields a `Syn`, by name or by a number `std.enums.fromInt` takes, `.none` refused: a 9P write refused in words (EINVAL, the rows text error), never drawn; a user could hit it with a script writing rows; the test (the change before) passes Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/locations.zig | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/locations.zig b/core/locations.zig index 10704912..041e9692 100644 --- a/core/locations.zig +++ b/core/locations.zig @@ -224,9 +224,12 @@ pub fn parseRows(arena: std.mem.Allocator, text: []const u8) error{ OutOfMemory, continue :names; }; if (style & syntax.syn_bits != 0) return error.BadRows; - const syn: u8 = if (std.meta.stringToEnum(syntax.Syn, name)) |known| @backingInt(known) else std.fmt.parseInt(u4, name, 10) catch return error.BadRows; - if (syn == 0) return error.BadRows; - style |= syn; + // A kind by its name or its number, one Syn has: the + // render takes the style's syntax bits as a Syn. + const syn = std.meta.stringToEnum(syntax.Syn, name) orelse + std.enums.fromInt(syntax.Syn, std.fmt.parseInt(u8, name, 10) catch return error.BadRows) orelse return error.BadRows; + if (syn == .none) return error.BadRows; + style |= @backingInt(syn); } @memset(row.colors[start..][0..n], style); } -- cgit v1.3