-
-
Notifications
You must be signed in to change notification settings - Fork 888
GIF: Check for end of stream when reading comments. #2954
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -414,6 +414,11 @@ private void ReadComments(BufferedReadStream stream) | |||||
| GifThrowHelper.ThrowInvalidImageContentException($"Gif comment length '{length}' exceeds max '{GifConstants.MaxCommentSubBlockLength}' of a comment data block"); | ||||||
| } | ||||||
|
|
||||||
| if (length == -1) | ||||||
| { | ||||||
| GifThrowHelper.ThrowInvalidImageContentException("Unexpected end of stream while reading gif comment"); | ||||||
|
||||||
| GifThrowHelper.ThrowInvalidImageContentException("Unexpected end of stream while reading gif comment"); | |
| GifThrowHelper.ThrowInvalidImageContentException("Unexpected end of stream while reading GIF comment"); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -381,4 +381,21 @@ public void Issue2859_LZWPixelStackOverflow<TPixel>(TestImageProvider<TPixel> pr | |||||
| image.DebugSaveMultiFrame(provider); | ||||||
| image.CompareToReferenceOutputMultiFrame(provider, ImageComparer.Exact); | ||||||
| } | ||||||
|
|
||||||
| // https://github.com/SixLabors/ImageSharp/issues/2953 | ||||||
| [Theory] | ||||||
| [WithFile(TestImages.Gif.Issues.Issue2953, PixelTypes.Rgba32)] | ||||||
| public void Issue2953<TPixel>(TestImageProvider<TPixel> provider) | ||||||
| where TPixel : unmanaged, IPixel<TPixel> | ||||||
| { | ||||||
| // We should throw a InvalidImageContentException when trying to identify or load an invalid GIF file. | ||||||
|
||||||
| // We should throw a InvalidImageContentException when trying to identify or load an invalid GIF file. | |
| // We should throw an InvalidImageContentException when trying to identify or load an invalid GIF file. |
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.
[nitpick] Consider moving the EOF check (
length < 0) before the max-length validation to follow a consistent ordering of bounds checks and avoid any accidental fall-through.