main.zig — @enumFromInt without validation for MessageTypemain.zig — @enumFromInt without validation for MessageTypeFile: src/main.zig:418
Severity: HIGH
Status: ✅ FIXED — added MessageType.fromByte() validation helper that returns null for invalid byte values. Both call sites in main.zig use orelse to handle the error (exit for recvPacket path, skip for interactive client). Tests added.
const msg_type = @as(protocol.MessageType, @enumFromInt(read_buf.items[read_pos + 4]));
If the byte doesn’t correspond to a declared MessageType value, this creates an invalid enum value, which is undefined behavior in Zig and can cause crashes or unpredictable switch dispatch.