Skip to content
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

Attempt to use undefined value #41

Closed
bookmoons opened this issue Nov 10, 2019 · 1 comment
Closed

Attempt to use undefined value #41

bookmoons opened this issue Nov 10, 2019 · 1 comment

Comments

@bookmoons
Copy link

Attempting to decode bytes 474946383961494638fd627a4421 raises an error:

TypeError: Cannot read property 'toString' of undefined

It seems to happen on line 459 of omggif.js:

                "Unknown graphic control label: 0x" + buf[p-1].toString(16));

This code reproduces:

const omggif = require('omggif')
const bytes = Buffer.from('474946383961494638fd627a4421', 'hex')
omggif.GifReader(bytes)

This was found by running jsfuzz on the module.

@deanm
Copy link
Owner

deanm commented Nov 27, 2021

Yeah, it makes sense there that we basically read off the end of the input. The consequence is that we throw an exception while trying to throw an exception, so in the end it's still throwing an exception (just maybe we could do a better job at the exception that's thrown). It's not really a goal of omggif to handle corrupted input super well or give you amazing error messages. It's a little bit more in the "garbage in garbage out" philosophy, in the name of performance, to not penalise the decoding of well-formed GIFs for the sake of making friendlier error message for invalid ones. Usually it can at least tell you it was garbage in, but I'm sure there are places where we will successful decode something that is probably technically broken.

I appreciate filing the bug though, but I would triage this as pretty low priority and not worth committing a fix for. In general I'm interested in either well formed GIFs not decoding correctly when they should (ie don't use features we don't support, etc), or invalid GIFs that somehow don't error out properly (infinite loop, etc).

Thanks!

@deanm deanm closed this as completed Nov 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants