summaryrefslogtreecommitdiff
path: root/src/9p_io.zig
diff options
context:
space:
mode:
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 };
}