From ecc37bfdc4b5771dfe4bda61b9ffab9ad298950d Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 1 Oct 2026 10:13:09 -0300 Subject: Mount dials: a relative socket path is a bad dial address, a socket path not there says no such socket (ENOENT), and the hint says tcp! takes a numeric address `Mount peer rel/x.sock` dialled relative to wherever the editor ran; `Mount peer unix!/nonexistent` said `dial failed: no answer` (EIO); and the hint offered `tcp!host!port` where only a numeric address is taken. Co-Authored-By: Claude Opus 5.5 --- src/9p_io.zig | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/9p_io.zig') diff --git a/src/9p_io.zig b/src/9p_io.zig index e199dea9..dd755f82 100644 --- a/src/9p_io.zig +++ b/src/9p_io.zig @@ -1427,6 +1427,7 @@ test "TCP addresses are numeric and normalize mapped IPv4" { 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("rel/dir.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")); @@ -2086,6 +2087,9 @@ pub const Client = struct { 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) { + // A socket's path is absolute: a relative one would mean wherever + // the editor happens to run. + if (path[0] != '/') return error.BadDial; if (std.mem.indexOfScalar(u8, path, 0) != null) return error.BadDial; return .{ .unix = std.fmt.bufPrintSentinel(buf, "{s}", .{path}, 0) catch return error.BadDial }; } -- cgit v1.3