From 239056c90f1ee73619feaa58e8d7553176a0e2be Mon Sep 17 00:00:00 2001 From: Khang Nguyen Duy Date: Fri, 20 Dec 2024 22:29:58 +0700 Subject: [PATCH] avoid asserting working directory is absolute `std.fs.accessAbsolute` asserts if the user proposed path is absolute, which we are seemingly passing as-is with no validating that it is. When running with safety checks on, passing non-absolute path to --working-directory will make ghostty crash. I changed it to use `Dir.access`, which is just `accessAbsolute` without the check. This has the side effect of also allowing relative working directory. --- src/termio/Exec.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index ea476e08c..423ebfa28 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -1135,7 +1135,7 @@ const Subprocess = struct { // This is important because our cwd can be set by the shell (OSC 7) // and we don't want to break new windows. const cwd: ?[]const u8 = if (self.cwd) |proposed| cwd: { - if (std.fs.accessAbsolute(proposed, .{})) { + if (std.fs.cwd().access(proposed, .{})) { break :cwd proposed; } else |err| { log.warn("cannot access cwd, ignoring: {}", .{err});