-
-
Notifications
You must be signed in to change notification settings - Fork 861
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
V3 : Fix GIF, PNG, and WEBP Edge Case Handling #2882
base: release/3.1.x
Are you sure you want to change the base?
Changes from 7 commits
6f38753
a888544
ef8c79d
bd1649d
2b239ec
f63ad84
7cecea9
9c5bcfa
386e17d
5d77de9
6da9bc3
33e5cbf
c4d314a
67fd9de
d33e6a9
f9f5257
f63e1a4
94df8e3
f80aa76
78b902b
6430b8e
bf66f24
b65abe7
eb6b0ab
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 |
---|---|---|
|
@@ -67,14 +67,14 @@ public Vp8Decoder(Vp8FrameHeader frameHeader, Vp8PictureHeader pictureHeader, Vp | |
int extraY = extraRows * this.CacheYStride; | ||
int extraUv = extraRows / 2 * this.CacheUvStride; | ||
this.YuvBuffer = memoryAllocator.Allocate<byte>((WebpConstants.Bps * 17) + (WebpConstants.Bps * 9) + extraY); | ||
this.CacheY = memoryAllocator.Allocate<byte>((16 * this.CacheYStride) + extraY); | ||
this.CacheY = memoryAllocator.Allocate<byte>((16 * this.CacheYStride) + extraY, AllocationOptions.Clean); | ||
int cacheUvSize = (16 * this.CacheUvStride) + extraUv; | ||
this.CacheU = memoryAllocator.Allocate<byte>(cacheUvSize); | ||
this.CacheV = memoryAllocator.Allocate<byte>(cacheUvSize); | ||
this.TmpYBuffer = memoryAllocator.Allocate<byte>((int)width); | ||
this.TmpUBuffer = memoryAllocator.Allocate<byte>((int)width); | ||
this.TmpVBuffer = memoryAllocator.Allocate<byte>((int)width); | ||
this.Pixels = memoryAllocator.Allocate<byte>((int)(width * height * 4)); | ||
this.CacheU = memoryAllocator.Allocate<byte>(cacheUvSize, AllocationOptions.Clean); | ||
this.CacheV = memoryAllocator.Allocate<byte>(cacheUvSize, AllocationOptions.Clean); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of celaning these, shouldn't we consider removing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can get away without cleaning everything but the |
||
this.TmpYBuffer = memoryAllocator.Allocate<byte>((int)width, AllocationOptions.Clean); | ||
this.TmpUBuffer = memoryAllocator.Allocate<byte>((int)width, AllocationOptions.Clean); | ||
this.TmpVBuffer = memoryAllocator.Allocate<byte>((int)width, AllocationOptions.Clean); | ||
this.Pixels = memoryAllocator.Allocate<byte>((int)(width * height * 4), AllocationOptions.Clean); | ||
|
||
#if DEBUG | ||
// Filling those buffers with 205, is only useful for debugging, | ||
|
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.
Is it necessary to clean the buffer given that we assume we will read
bytesToRead
bytes anyways? And coming to the assumption: instead of ignoring theinput.Read()
result, shouldn't we fail the read and abort processing the stream if it's<bytesToRead
?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.
I just don't think it's a good idea to do any uncleaned buffer reading in the decoders now we've had CVEs due to it.
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.
It always depends on the particular buffer usage. This is a a raw chunk buffer that is to be transformed as part of the decoding process, and the raw contents won't show up in image buffers. In any case, ignoring the read result seems to be more worrying and implementing proper handling of the read result would render
Clean
unnecessary.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.
I've rereviewed and in this case there are lots of places expecting the data span to be the requested length. It's much easier for me to clean the array than refactor.