summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/9p_io.zig5
-rw-r--r--src/ninep/ctl.zig8
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");
+}