Skip to content

Commit 981ec16

Browse files
committedFeb 5, 2025
8347911: Limit the length of inflated text chunks
Reviewed-by: andrew Backport-of: 398a580518b4e7961bdddf733e0a89ff25bc437a
1 parent caa7cc2 commit 981ec16

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

Diff for: ‎src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -142,6 +142,7 @@ public class PNGImageReader extends ImageReader {
142142
static final int tRNS_TYPE = 0x74524e53;
143143
static final int zTXt_TYPE = 0x7a545874;
144144

145+
static final int MAX_INFLATED_TEXT_LENGTH = 262144;
145146
static final int PNG_COLOR_GRAY = 0;
146147
static final int PNG_COLOR_RGB = 2;
147148
static final int PNG_COLOR_PALETTE = 3;
@@ -670,7 +671,7 @@ private void parse_tRNS_chunk(int chunkLength) throws IOException {
670671
private static byte[] inflate(byte[] b) throws IOException {
671672
InputStream bais = new ByteArrayInputStream(b);
672673
try (InputStream iis = new InflaterInputStream(bais)) {
673-
return iis.readAllBytes();
674+
return iis.readNBytes(MAX_INFLATED_TEXT_LENGTH);
674675
}
675676
}
676677

0 commit comments

Comments
 (0)