-
Notifications
You must be signed in to change notification settings - Fork 625
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
Fix potential overflow in GIF decoding #1036
Conversation
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.
Not the location I would suspected many bugs. Great!
Is it even used for any delay with numerator |
No, but it would be necessary to exactly encode something like 60 Hz. Though an integer number of nanoseconds for frame delay might also have low enough error to not matter? |
Apparently it doesn't really matter for |
Sounds good. Also, this is a breaking change since I've renamed some things/changed the type. Should I be pushing this to the next branch? |
Right. That poses the question: Are the type changes necessary? We will have some arbitrary maximum supported frame delay in either case. While
and clearly document this saturation. We surely don't want to error on decoding this and it's the most accurate replacement value. |
Add: I just noted that |
@fintelia Do you think we can/should land this for |
This changes a couple methods on |
Ah right, yes, change the target to |
@fintelia Reminder that you wanted to rebase this on |
bdc1a55
to
38232ee
Compare
Rebased. If everything looks good, lets merge once CI passes |
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.
All concerns were over breaking the interface. The new names and types are more consistent so for next
this is positive instead.
Fixes: #877
That issue was caused by an overflow in the "frame delay" field between individual frames of the GIF frames when expressed in milliseconds. This translates to highly unrealistic frame rates of greater than 65 seconds per frame (i.e. over 1000x slower than a normal monitor refresh rate), but ideally should still not result in panics. This PR switches to using u32's to prevent the possibility of overflow while still allowing all delay values expressible by GIF images.
At the same time I noticed that there was some confusion about the actual units used to store frame delays in various places. I've renamed a bunch of places to "delay_ms" to be clear when milliseconds are in use.
Open questions: Is num_rational::Ratio really the right type to express the delay in milliseconds between frames of an animation?