Skip to content

Commit

Permalink
Fix length check in PngMetadataReader
Browse files Browse the repository at this point in the history
  • Loading branch information
iamcarbon committed Feb 2, 2024
1 parent f4437f5 commit 59f4294
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions MetadataExtractor/Formats/Png/PngMetadataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,17 +332,19 @@ private static IEnumerable<Directory> ProcessChunk(PngChunk chunk)
{
directory.AddError("Insufficient bytes for PNG pHYs chunk.");
}
else
{
var reader = new BufferReader(bytes, isBigEndian: true);

var reader = new BufferReader(bytes, isBigEndian: true);

var pixelsPerUnitX = reader.GetInt32();
var pixelsPerUnitY = reader.GetInt32();
var unitSpecifier = reader.GetSByte();
var pixelsPerUnitX = reader.GetInt32();
var pixelsPerUnitY = reader.GetInt32();
var unitSpecifier = reader.GetSByte();

directory.Set(PngDirectory.TagPixelsPerUnitX, pixelsPerUnitX);
directory.Set(PngDirectory.TagPixelsPerUnitY, pixelsPerUnitY);
directory.Set(PngDirectory.TagUnitSpecifier, unitSpecifier);
yield return directory;
directory.Set(PngDirectory.TagPixelsPerUnitX, pixelsPerUnitX);
directory.Set(PngDirectory.TagPixelsPerUnitY, pixelsPerUnitY);
directory.Set(PngDirectory.TagUnitSpecifier, unitSpecifier);
yield return directory;
}
}
else if (chunkType.Equals(PngChunkType.sBIT))
{
Expand Down

0 comments on commit 59f4294

Please sign in to comment.