Skip to content

Commit

Permalink
Better PNG chunk length error message
Browse files Browse the repository at this point in the history
Closes #272
  • Loading branch information
drewnoakes committed Nov 24, 2017
1 parent 52cdffe commit e91bdb3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Source/com/drew/imaging/png/PngChunkReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ public Iterable<PngChunk> extract(@NotNull final SequentialReader reader, @Nulla
// Process the next chunk.
int chunkDataLength = reader.getInt32();

if (chunkDataLength < 0)
throw new PngProcessingException("PNG chunk length exceeds maximum");

PngChunkType chunkType = new PngChunkType(reader.getBytes(4));

boolean willStoreChunk = desiredChunkTypes == null || desiredChunkTypes.contains(chunkType);
Expand Down

0 comments on commit e91bdb3

Please sign in to comment.