-
-
Notifications
You must be signed in to change notification settings - Fork 852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tiff decoding robustness improvements #2550
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
// Licensed under the Six Labors Split License. | ||
|
||
// ReSharper disable InconsistentNaming | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.Intrinsics.X86; | ||
using SixLabors.ImageSharp.Formats; | ||
using SixLabors.ImageSharp.Formats.Tiff; | ||
|
@@ -352,7 +351,7 @@ | |
[Theory] | ||
[WithFile(Rgba8BitAssociatedAlpha, PixelTypes.Rgba32)] | ||
public void TiffDecoder_CanDecode_32Bit_WithAssociatedAlpha<TPixel>(TestImageProvider<TPixel> provider) | ||
// Note: Using tolerant comparer here, because there is a small difference to the reference decoder probably due to floating point rounding issues. | ||
Check warning on line 354 in tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs GitHub Actions / Build (false, windows-latest, net7.0, 7.0.x, true, -x64, false)
Check warning on line 354 in tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs GitHub Actions / Build (false, windows-latest, net6.0, 6.0.x, -x64, false)
|
||
where TPixel : unmanaged, IPixel<TPixel> => TestTiffDecoder(provider, useExactComparer: false, compareTolerance: 0.004F); | ||
|
||
[Theory] | ||
|
@@ -666,6 +665,33 @@ | |
public void TiffDecoder_CanDecode_TiledWithNonEqualWidthAndHeight<TPixel>(TestImageProvider<TPixel> provider) | ||
where TPixel : unmanaged, IPixel<TPixel> => TestTiffDecoder(provider); | ||
|
||
[Theory] | ||
[WithFile(JpegCompressedGray0000539558, PixelTypes.Rgba32)] | ||
public void TiffDecoder_ThrowsException_WithCircular_IFD_Offsets<TPixel>(TestImageProvider<TPixel> provider) | ||
where TPixel : unmanaged, IPixel<TPixel> | ||
=> Assert.Throws<ImageFormatException>( | ||
() => | ||
{ | ||
using (provider.GetImage(TiffDecoder.Instance)) | ||
{ | ||
} | ||
}); | ||
|
||
[Theory] | ||
[WithFile(Tiled0000023664, PixelTypes.Rgba32)] | ||
public void TiffDecoder_CanDecode_TiledWithBadZlib<TPixel>(TestImageProvider<TPixel> provider) | ||
where TPixel : unmanaged, IPixel<TPixel> | ||
{ | ||
using Image<TPixel> image = provider.GetImage(TiffDecoder.Instance); | ||
|
||
// ImageMagick cannot decode this image. | ||
image.DebugSave(provider); | ||
image.CompareToReferenceOutput( | ||
ImageComparer.Exact, | ||
antonfirsov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
provider, | ||
appendPixelTypeToFileName: false); | ||
} | ||
|
||
[Theory] | ||
[WithFileCollection(nameof(MultiframeTestImages), PixelTypes.Rgba32)] | ||
public void DecodeMultiframe<TPixel>(TestImageProvider<TPixel> provider) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...ut/TiffDecoderTests/TiffDecoder_CanDecode_TiledWithBadZlib_tiled-0000023664.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
tests/Images/Input/Tiff/Issues/JpegCompressedGray-0000539558.tiff
Git LFS file not shown
Git LFS file not shown
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are already touching this class: we should check the return value of
this.innerStream.Read
inInitializeInflateStream
when it's skipping 4 bytes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed the change together with another check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good changes. Thanks!