diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-01 08:42:44 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 08:53:11 -0300 |
| commit | 9fddd372ed88886bf98e5c9d5ca88cee9a272357 (patch) | |
| tree | f9a70b48f101d644966f272c0797e67b6d3f9b02 /src | |
| parent | 84b3bb51d7009902659e05f94c53c82d109ba8f6 (diff) | |
| download | pardes-9fddd372ed88886bf98e5c9d5ca88cee9a272357.tar.gz pardes-9fddd372ed88886bf98e5c9d5ca88cee9a272357.zip | |
A Mount dial with a network pardes does not dial (`nowhere!x`) is a bad dial address, EINVAL, not a session name that does not answer
A dial with a `!` and no `/` that was neither tcp!, quic! nor unix! was
taken for a session's name, failing as `dial failed: no answer`, EIO.
It is now refused as the malformed address it is, before any dial. A
path with a `!` in it still dials.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/9p_io.zig | 5 | ||||
| -rw-r--r-- | src/ninep/ctl.zig | 8 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/9p_io.zig b/src/9p_io.zig index a4340ddf..e199dea9 100644 --- a/src/9p_io.zig +++ b/src/9p_io.zig @@ -1425,6 +1425,8 @@ test "TCP addresses are numeric and normalize mapped IPv4" { try Client.validateDial("/tmp/pardes-owned.sock"); try Client.validateDial("unix!/tmp/pardes-owned.sock"); try testing.expectError(error.BadDial, Client.validateDial("unix!work")); + try testing.expectError(error.BadDial, Client.validateDial("nowhere!x")); + try Client.validateDial("/tmp/odd!name.sock"); try testing.expectError(error.BadDial, Client.validateDial("unix!")); try testing.expectError(error.BadDial, Client.validateDial("unix!/tmp/a\x00b")); try testing.expectError(error.BadDial, Client.validateDial("tcp!localhost!5640")); @@ -2078,6 +2080,9 @@ pub const Client = struct { return .{ .quic = try networkAddress(dial, false) }; } const explicit_unix = std.mem.startsWith(u8, dial, "unix!"); + // A network this does not dial (`nowhere!x`) is a malformed address, + // not a session named so. + if (!explicit_unix and std.mem.indexOfScalar(u8, dial, '/') == null and std.mem.indexOfScalar(u8, dial, '!') != null) return error.BadDial; const path = if (explicit_unix) dial[5..] else dial; if (explicit_unix and !std.mem.startsWith(u8, path, "/")) return error.BadDial; if (std.mem.indexOfScalar(u8, path, '/') != null) { diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index d4d09e0b..3ec1f4d6 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -4371,3 +4371,11 @@ test "DumpDir refuses a relative directory and one that may not be written, up f p.dumpFailed("/proc/1/root/x/pardes.dump.zon", error.FileNotFound); try testing.expect(std.mem.endsWith(u8, p.fs.late_failure[0..p.fs.late_failure_len], ": permission denied")); } + +test "a Mount dial with a network it does not know is a bad dial address, EINVAL" { + const p = try withFile(testing.allocator, "x\n"); + defer p.deinit(); + const r = wr(p, @intFromEnum(tree.TopFile.ctl), "Mount peer nowhere!x\n"); + try testing.expectEqual(E.INVAL, r.errno()); + try testing.expectStringStartsWith(r.reply.ename, "Mount: bad dial address: nowhere!x"); +} |
