Fix cstring init (#420)

pull/421/head^2
Max Goedjen 1 month ago committed by GitHub
parent 47d736cb0d
commit 20cbaac6f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      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<UInt8>.allocate(capacity: Int(MAXPATHLEN))
_ = proc_pidpath(pid, pathPointer, UInt32(MAXPATHLEN))
let path = String(cString: pathPointer)

Loading…
Cancel
Save