summaryrefslogtreecommitdiff
path: root/src/9p_io.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-01 10:13:09 -0300
committerGabriel Schneider <[email protected]>2026-10-01 10:36:27 -0300
commitecc37bfdc4b5771dfe4bda61b9ffab9ad298950d (patch)
tree8acec3b0a727b2ac41963c4739a2a6fd3e7b94e4 /src/9p_io.zig
parent13c5f281ae0264e42e04bce527b83159fa75466c (diff)
downloadpardes-ecc37bfdc4b5771dfe4bda61b9ffab9ad298950d.tar.gz
pardes-ecc37bfdc4b5771dfe4bda61b9ffab9ad298950d.zip
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 <[email protected]>
Diffstat (limited to 'src/9p_io.zig')
-rw-r--r--src/9p_io.zig4
1 files changed, 4 insertions, 0 deletions
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 };
}