From 582beeec6c6ff40637f511b89addc915bf669cf0 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 29 Nov 2024 00:55:35 +0800 Subject: [PATCH] Close isExecutable command outpipe file handle after use Prevents exhaustion of fds Signed-off-by: Claudio Cambra --- admin/osx/mac-crafter/Sources/Utils/Codesign.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/admin/osx/mac-crafter/Sources/Utils/Codesign.swift b/admin/osx/mac-crafter/Sources/Utils/Codesign.swift index b511f0a443e27..f262ff39d7bac 100644 --- a/admin/osx/mac-crafter/Sources/Utils/Codesign.swift +++ b/admin/osx/mac-crafter/Sources/Utils/Codesign.swift @@ -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") }