Commit Graph
7 Commits
Author SHA1 Message Date
Sebastien Tardif c3153dc39f Close JarFile when finding main class from archive
MainClassFinder.findSingleMainClass(JarFile, ...) does not close the
JarFile; the caller owns the resource. FindMainClass passed a newly
opened JarFile without closing it, unlike sibling call sites that use
try-with-resources.

See gh-50949

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
2026-07-16 11:08:06 +02:00
Sebastien Tardif 7bdb1320bf Close streams and delete intermediate temps in ImageBuildpack
ExportedLayers left the intermediate create-builder-scratch-source
temp file behind after rebased layer files were written, and opened
layer InputStreams without closing them when StreamUtils.copy does
not close either stream. Delete the source temp in a finally block
and use try-with-resources for the apply path so layer files can be
deleted reliably.

See gh-50919

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
2026-07-14 08:33:33 +02:00
Sebastien Tardif eaf4a0a286 Close FileOutputStream delegate in InspectingOutputStream
InspectingOutputStream extends OutputStream but does not override
close(). When content exceeds MEMORY_LIMIT (approximately 4 KB),
convertToTempFile() replaces the ByteArrayOutputStream delegate with a
FileOutputStream. The try-with-resources in InspectedContent.of() calls
close(), which inherits the no-op OutputStream.close(), leaving the
FileOutputStream open and leaking a file descriptor.

Override close() to delegate to the underlying stream.

See gh-50639

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
2026-05-31 16:13:46 +02:00
Sebastien Tardif 6d9fd88ae9 Close URLClassLoader in ArchitectureCheck
See gh-50626

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
2026-05-30 16:34:19 +02:00
Sebastien Tardif 8a28cefd08 Restore interrupt flag in ProcessRunner on InterruptedException
ProcessRunner.waitForProcess and ReaderThread.toString catch
InterruptedException without restoring the thread interrupt flag.
This prevents callers higher up the stack from detecting the
interruption. Every other InterruptedException handler in the
codebase restores the flag; these two were the only omissions.

Add Thread.currentThread().interrupt() before re-throwing or
returning in both catch blocks. Also chain the original exception
as the cause in waitForProcess for debuggability.

See gh-50451

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
2026-05-29 12:20:51 +02:00
Sebastien Tardif f318c93133 Add size validation for long-to-int casts in buildpack module
Add explicit size checks before casting long values to int in
Content.of(File) and LogUpdateEvent.read() to prevent silent data
corruption or NegativeArraySizeException when processing large files
or malformed Docker stream data.

See gh-50382

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
2026-05-12 11:46:09 -07:00
Sebastien Tardif eb90d0de63 Align DocumentBuilderFactory configuration
Align configuration used for `DocumentBuilderFactory` instances
across the codebase.

See gh-50282

Signed-off-by: Sebastien Tardif <SebTardif@ncf.ca>
2026-05-04 13:36:12 -07:00