summaryrefslogtreecommitdiff
path: root/src/9p_io.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-01 08:42:44 -0300
committerGabriel Schneider <[email protected]>2026-10-01 08:53:11 -0300
commit9fddd372ed88886bf98e5c9d5ca88cee9a272357 (patch)
treef9a70b48f101d644966f272c0797e67b6d3f9b02 /src/9p_io.zig
parent84b3bb51d7009902659e05f94c53c82d109ba8f6 (diff)
downloadpardes-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/9p_io.zig')
-rw-r--r--src/9p_io.zig5
1 files changed, 5 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) {