Browse Source
Apply suggestions from code review
Co-authored-by: Günther Foidl <gue@korporal.at>
pull/2110/head
Brian Popow
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
8 additions and
6 deletions
-
src/ImageSharp/Formats/Png/PngDecoderCore.cs
-
src/ImageSharp/Formats/Png/PngEncoderCore.cs
|
|
|
@ -1186,7 +1186,7 @@ namespace SixLabors.ImageSharp.Formats.Png |
|
|
|
private void ReadColorProfileChunk(ImageMetadata metadata, ReadOnlySpan<byte> data) |
|
|
|
{ |
|
|
|
int zeroIndex = data.IndexOf((byte)0); |
|
|
|
if (zeroIndex < PngConstants.MinTextKeywordLength || zeroIndex > PngConstants.MaxTextKeywordLength) |
|
|
|
if (zeroIndex is < PngConstants.MinTextKeywordLength or > PngConstants.MaxTextKeywordLength) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
@ -694,11 +694,13 @@ namespace SixLabors.ImageSharp.Formats.Png |
|
|
|
int bytesWritten = PngConstants.XmpKeyword.Length; |
|
|
|
|
|
|
|
// Write the iTxt header (all zeros in this case).
|
|
|
|
payload[bytesWritten++] = 0; |
|
|
|
payload[bytesWritten++] = 0; |
|
|
|
payload[bytesWritten++] = 0; |
|
|
|
payload[bytesWritten++] = 0; |
|
|
|
payload[bytesWritten++] = 0; |
|
|
|
Span<byte> iTxtHeader = payload.Slice(bytesWritten); |
|
|
|
iTxtHeader[4] = 0; |
|
|
|
iTxtHeader[3] = 0; |
|
|
|
iTxtHeader[2] = 0; |
|
|
|
iTxtHeader[1] = 0; |
|
|
|
iTxtHeader[0] = 0; |
|
|
|
bytesWritten += 5; |
|
|
|
|
|
|
|
// And the XMP data itself.
|
|
|
|
xmpData.CopyTo(payload.Slice(bytesWritten)); |
|
|
|
|