Skip to content

Commit bb6b048

Browse files
author
Eirik Bjørsnøs
committedFeb 26, 2024
8326099: GZIPOutputStream should use Deflater.getBytesRead() instead of Deflater.getTotalIn()
Reviewed-by: jpai
1 parent 490825f commit bb6b048

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed
 

‎src/java.base/share/classes/java/util/zip/GZIPOutputStream.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ private void writeHeader() throws IOException {
212212
*/
213213
private void writeTrailer(byte[] buf, int offset) throws IOException {
214214
writeInt((int)crc.getValue(), buf, offset); // CRC-32 of uncompr. data
215-
writeInt(def.getTotalIn(), buf, offset + 4); // Number of uncompr. bytes
215+
// RFC 1952: Size of the original (uncompressed) input data modulo 2^32
216+
int iSize = (int) def.getBytesRead();
217+
writeInt(iSize, buf, offset + 4);
216218
}
217219

218220
/*

0 commit comments

Comments
 (0)
Please sign in to comment.