summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 2b366de0..89c2e5dd 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -4333,3 +4333,27 @@ test "a look of ./x that is not there is a miss, as x and /abs/x are: answered,
}
try testing.expect(th.logHas(p, "look: ./zzq-nosuch.txt: no such file"));
}
+
+test "a ctl line over 1 MiB is refused once, EINVAL, and its tail is not run as a line of its own" {
+ const p = try withFile(testing.allocator, "x\n");
+ defer p.deinit();
+ const node = Node.of(serialOf(p), .ctl);
+ const h = call(p, .{ .tag = 1, .op = .open, .node = node, .omode = 1 }).reply.handle;
+ const chunk: [4096]u8 = @splat('z');
+ var refused: usize = 0;
+ var off: u64 = 0;
+ for (0..270) |_| {
+ const r = call(p, .{ .tag = 2, .op = .write, .node = node, .handle = h, .off = off, .data = &chunk });
+ if (r.reply.status == .err) {
+ refused += 1;
+ try testing.expectEqual(E.INVAL, r.errno());
+ }
+ off += chunk.len;
+ }
+ try testing.expectEqual(Status.ok, call(p, .{ .tag = 3, .op = .write, .node = node, .handle = h, .off = off, .data = "zzz\nEdit ,d\n" }).reply.status);
+ try testing.expectEqual(@as(usize, 1), refused);
+ try testing.expect(!th.logHas(p, "unknown control message"));
+ // What came after the long line's newline ran.
+ try testing.expectEqualStrings("", pane_files.fileOf(p.panes[0].?).?.content);
+ _ = call(p, .{ .tag = 4, .op = .release, .node = node, .handle = h });
+}