Close isExecutable command outpipe file handle after use

Prevents exhaustion of fds

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-11-29 00:55:35 +08:00 committed by Matthieu Gallien
parent fb78b0fb0c
commit 582beeec6c

View File

@ -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")
}