diff --git a/config/scripts/check-styled-scrollbars.test.mjs b/config/scripts/check-styled-scrollbars.test.mjs index 5ab2f46b1..c6ff4a72a 100644 --- a/config/scripts/check-styled-scrollbars.test.mjs +++ b/config/scripts/check-styled-scrollbars.test.mjs @@ -175,7 +175,7 @@ describe('check-styled-scrollbars', () => { it('uses later spread className props over earlier explicit className props', () => { const reports = reportUnstyledScrollbars( 'Example.tsx', - "export function Example() { return
}" + 'export function Example() { return }' ) expect(reports).toHaveLength(1) diff --git a/native/computer-use-macos/Sources/OrcaComputerUseMacOS/main.swift b/native/computer-use-macos/Sources/OrcaComputerUseMacOS/main.swift index eaadb8553..1094fc9e5 100644 --- a/native/computer-use-macos/Sources/OrcaComputerUseMacOS/main.swift +++ b/native/computer-use-macos/Sources/OrcaComputerUseMacOS/main.swift @@ -3044,11 +3044,11 @@ private final class SocketListener: @unchecked Sendable { close(socketFd) socketFd = -1 } - unlink(socketPath) + // Why: the parent owns the private temp directory cleanup; the helper + // must not unlink arbitrary caller-supplied paths on shutdown. } private func bindSocket() throws { - unlink(socketPath) socketFd = socket(AF_UNIX, SOCK_STREAM, 0) guard socketFd >= 0 else { throw ProviderError.coded("accessibility_error", "failed to create computer-use socket") @@ -3072,9 +3072,16 @@ private final class SocketListener: @unchecked Sendable { } } guard result == 0 else { - let message = String(cString: strerror(errno)) + let bindErrno = errno + let message = String(cString: strerror(bindErrno)) close(socketFd) socketFd = -1 + if UnixSocketPathSafety.shouldRejectExistingPathAfterBindFailure( + bindErrno: bindErrno, + existingMode: existingPathMode(socketPath) + ) { + throw ProviderError.coded("invalid_argument", "refusing to replace non-socket file at computer-use socket path") + } throw ProviderError.coded("accessibility_error", "failed to bind computer-use socket: \(message)") } chmod(socketPath, 0o600) @@ -3124,6 +3131,14 @@ private final class SocketListener: @unchecked Sendable { } } +private func existingPathMode(_ path: String) -> mode_t? { + var statInfo = stat() + guard lstat(path, &statInfo) == 0 else { + return nil + } + return statInfo.st_mode +} + private func peerProcessId(_ fd: Int32) -> pid_t? { var pid = pid_t(0) var length = socklen_t(MemoryLayout