|
|
|
@ -1141,19 +1141,22 @@ namespace SixLabors.ImageSharp.Formats.Png |
|
|
|
/// <param name="chunk">The <see cref="PngChunk"/>.</param>
|
|
|
|
private void ValidateChunk(in PngChunk chunk) |
|
|
|
{ |
|
|
|
Span<byte> chunkType = stackalloc byte[4]; |
|
|
|
uint crc = this.ReadChunkCrc(); |
|
|
|
|
|
|
|
BinaryPrimitives.WriteUInt32BigEndian(chunkType, (uint)chunk.Type); |
|
|
|
if (chunk.IsCritical) |
|
|
|
{ |
|
|
|
Span<byte> chunkType = stackalloc byte[4]; |
|
|
|
BinaryPrimitives.WriteUInt32BigEndian(chunkType, (uint)chunk.Type); |
|
|
|
|
|
|
|
this.crc.Reset(); |
|
|
|
this.crc.Update(chunkType); |
|
|
|
this.crc.Update(chunk.Data.GetSpan()); |
|
|
|
this.crc.Reset(); |
|
|
|
this.crc.Update(chunkType); |
|
|
|
this.crc.Update(chunk.Data.GetSpan()); |
|
|
|
|
|
|
|
uint crc = this.ReadChunkCrc(); |
|
|
|
if (this.crc.Value != crc && chunk.IsCritical) |
|
|
|
{ |
|
|
|
string chunkTypeName = Encoding.ASCII.GetString(chunkType); |
|
|
|
PngThrowHelper.ThrowInvalidChunkCrc(chunkTypeName); |
|
|
|
if (this.crc.Value != crc) |
|
|
|
{ |
|
|
|
string chunkTypeName = Encoding.ASCII.GetString(chunkType); |
|
|
|
PngThrowHelper.ThrowInvalidChunkCrc(chunkTypeName); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|