summaryrefslogtreecommitdiff
path: root/src/ninep/tree.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-01 23:20:19 -0300
committerGabriel Schneider <[email protected]>2026-10-01 23:22:39 -0300
commitdd6a3c2c367cee12a8e2da81e7da6a2c8f3103d5 (patch)
tree3c2acaf6836af9c52b7cfbf201a2c1b533512d10 /src/ninep/tree.zig
parente4562384ac910b78254ec7aaaecad8b74717f2ee (diff)
downloadpardes-dd6a3c2c367cee12a8e2da81e7da6a2c8f3103d5.tar.gz
pardes-dd6a3c2c367cee12a8e2da81e7da6a2c8f3103d5.zip
Round 39's small ones: a name write past its one line is refused by that write; Get and Edit's e load over a scratch under 100 bytes unasked, as Del closes it; Putall saves a Zerox pair once; bare Tab on the root ctl says the width as from a pane, and a ctl check of Tab no longer sets it; a directory read is "is a directory" (EISDIR), an unreadable file "permission denied" (EACCES), Incl of a file "not a directory" (ENOTDIR), and a device "not a regular file", never read to the stream limit
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep/tree.zig')
-rw-r--r--src/ninep/tree.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig
index 1990d09e..c78a1aa2 100644
--- a/src/ninep/tree.zig
+++ b/src/ninep/tree.zig
@@ -1270,6 +1270,16 @@ fn writeLines(p: *Pardes, req: Req, target: Target) Reply {
data = data[nl + 1 ..];
if (data.len == 0) return .{ .tag = req.tag, .written = @intCast(req.data.len) };
}
+ // One name an open, on one line: anything after its newline, in this
+ // write or a later one, is refused by the write that brings it, never
+ // left to rename the pane again at the close (`printf 'a\nb' > name`).
+ if (target == .pane and target.pane.file == .name) {
+ const past_newline = if (std.mem.indexOfScalar(u8, data, '\n')) |nl| nl + 1 < data.len else false;
+ if (o.named or past_newline) {
+ o.pending.clearRetainingCapacity();
+ return failText(req.tag, E.INVAL, "invalid file name: one name a write, on one line");
+ }
+ }
o.pending.appendSlice(p.gpa, data) catch return Reply.fail(req.tag, E.NOMEM);
// A line runs when its newline comes, or, the last one, when its open
// is let go (release). Nothing is inferred from a write's size: a mount