From e2a8cb943b29ffbf796c05673e259615e39335c1 Mon Sep 17 00:00:00 2001 From: Max Goedjen Date: Thu, 27 Oct 2022 00:14:09 -0700 Subject: [PATCH] Fix cstring init --- .../Sources/SecretAgentKit/SigningRequestTracer.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/Packages/Sources/SecretAgentKit/SigningRequestTracer.swift b/Sources/Packages/Sources/SecretAgentKit/SigningRequestTracer.swift index 46917f8..7e87538 100644 --- a/Sources/Packages/Sources/SecretAgentKit/SigningRequestTracer.swift +++ b/Sources/Packages/Sources/SecretAgentKit/SigningRequestTracer.swift @@ -40,7 +40,10 @@ extension SigningRequestTracer { func process(from pid: Int32) -> SigningRequestProvenance.Process { var pidAndNameInfo = self.pidAndNameInfo(from: pid) let ppid = pidAndNameInfo.kp_eproc.e_ppid != 0 ? pidAndNameInfo.kp_eproc.e_ppid : nil - let procName = String(cString: &pidAndNameInfo.kp_proc.p_comm.0) + let procName = withUnsafeMutablePointer(to: &pidAndNameInfo.kp_proc.p_comm.0) { pointer in + String(cString: pointer) + } + let pathPointer = UnsafeMutablePointer.allocate(capacity: Int(MAXPATHLEN)) _ = proc_pidpath(pid, pathPointer, UInt32(MAXPATHLEN)) let path = String(cString: pathPointer)