Skip to content

Commit

Permalink
Prevent bounds exception in BmpReader
Browse files Browse the repository at this point in the history
Contributes to #561
  • Loading branch information
drewnoakes committed Apr 3, 2022
1 parent a1ddc1b commit cde596d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Source/com/drew/metadata/bmp/BmpReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ protected void readBitmapHeader(@NotNull final SequentialReader reader, final @N
if (csType == ColorSpaceType.PROFILE_EMBEDDED.getValue() || csType == ColorSpaceType.PROFILE_LINKED.getValue()) {
long profileOffset = reader.getUInt32();
int profileSize = reader.getInt32();
if (profileSize < 0) {
directory.addError("Invalid profile size " + profileSize);
return;
}
if (reader.getPosition() > headerOffset + profileOffset) {
directory.addError("Invalid profile data offset 0x" + Long.toHexString(headerOffset + profileOffset));
return;
Expand Down

0 comments on commit cde596d

Please sign in to comment.