From 3d0d5e5de54611a88826600365bf0849d9ac4871 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 30 Sep 2026 17:14:40 -0300 Subject: A tag rewrite counts its text without the newline it drops: echo of exactly 4096 bytes fits `echo <4096 bytes> > tag` wrote 4097 bytes and was refused "over 4096 bytes", although a rewrite drops that one trailing newline and would have held exactly 4096. The limit now counts a truncating write's text without the newline it drops, for a pane's, a column's and the workspace's tag. An append still counts its newline, which it keeps. Co-Authored-By: Claude Opus 5.5 --- src/ninep/pane.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/ninep/pane.zig') diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig index fef0f85f..d5f2f20a 100644 --- a/src/ninep/pane.zig +++ b/src/ninep/pane.zig @@ -662,7 +662,11 @@ fn writeTag(p: *Pardes, req: Req, pane: *Pane) Reply { // is a text like any other (acme's tag file appends the same way). const had = if (pf.tag_trunc_pending) 0 else tagline.curTail(pane).len; const room = limits.max_tag_tail -| had -| @intFromBool(pf.tag_held_newline and !pf.tag_trunc_pending); - if (req.data.len > room) { + // A rewrite drops its one trailing newline: `echo <4096 bytes> > tag` + // is 4096 bytes of tag, and fits. + const rewrite = pf.tag_rewrite or pf.tag_trunc_pending; + const counted = req.data.len - @intFromBool(rewrite and req.data[req.data.len - 1] == '\n'); + if (counted > room) { pf.tag_trunc_pending = false; return tree.failText(req.tag, E.NOSPC, e_tag_over); } -- cgit v1.3