copyZipEntryToOutputStream

private fun copyZipEntryToOutputStream(zipInputStream: ZipInputStream, outputStream: BufferedOutputStream, initialTotalUnpackedBytes: Long): Long

Streams the current zip entry to outputStream while enforcing both the per-entry and cumulative archive size limits. Size accounting is performed against actual decompressed bytes read from the stream rather than ZipEntry.getSize, which is attacker-controlled metadata and therefore untrustworthy for zip bomb defense. Throws IOException if maxUnpackedZipEntrySizeBytes or maxUnpackedZipSizeBytes would be exceeded; the caller converts this into a rejected archive.

Return

the updated cumulative byte total after this entry completes.

Parameters

zipInputStream

the active zip stream positioned inside the current entry.

outputStream

the destination stream for the current entry.

initialTotalUnpackedBytes

cumulative bytes already written for previous entries.