szn

Bug 89 — logFn writes garbage bytes from uninitialized buffer on bufPrint failure

89. logFn writes garbage bytes from uninitialized buffer on bufPrint failure

File: src/main.zig:70–78 Severity: MEDIUM Status: ✅ FIXED — catch block writes prefix + fallback directly instead of using buf.

const msg = std.fmt.bufPrint(buf[prefix.len..], format, args) catch "log message too long";
const total_len = prefix.len + msg.len;
if (total_len < buf.len) {
    buf[total_len] = '\n';
    writeAllRaw(fd, buf[0 .. total_len + 1]);

When bufPrint fails, msg points to the static literal "log message too long" — outside buf. The code writes buf[prefix.len..total_len] which is uninitialized stack garbage between the prefix end and the start of the literal.

Fix: The catch block now writes the prefix and fallback string directly via writeAllRaw and returns early, never reading uninitialized stack memory.