Skip to content

Commit

Permalink
Close isExecutable command outpipe file handle after use
Browse files Browse the repository at this point in the history
Prevents exhaustion of fds

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
  • Loading branch information
claucambra authored and mgallien committed Dec 10, 2024
1 parent fb78b0f commit 582beee
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion admin/osx/mac-crafter/Sources/Utils/Codesign.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ func isExecutable(_ path: String) throws -> Bool {
throw CodeSigningError.failedToCodeSign("Failed to determine if \(path) is an executable.")
}

let outputData = outPipe.fileHandleForReading.readDataToEndOfFile()
let outputFileHandle = outPipe.fileHandleForReading
let outputData = outputFileHandle.readDataToEndOfFile()
try outputFileHandle.close()
let output = String(data: outputData, encoding: .utf8) ?? ""
return output.contains("Mach-O 64-bit executable")
}
Expand Down

0 comments on commit 582beee

Please sign in to comment.