-
Notifications
You must be signed in to change notification settings - Fork 1
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
Search acTL
only among chunk types
#4
Conversation
Byte sequence `acTL` can be encountered in other parts of PNG, that are not chunk type (e.g. in chunk data or crc), so we should check only chunk types to avoid false positive detection.
Thanks for the valid improvement. Before merging this and pushing a new release, do you have any ideas how we could early bail here, in order to prevent 'parsing' the entire file in special cases*. I tried figuring out the maximum length of content before an * In case a PNG file has a valid signature, but erroneous content (by accident or on purpose). |
* Added additional tests for input validation handling and data structure constraints * Removed test related to string matching
I don't think it would be possible to prevent simulating worst case scenario even if we fully validate all png chunks. Judging by spec png file can consist of sequence of small chunks (our worst-case scenario, performance-wise) and still be valid. Either way, even in worst case complexity won't exceed
|
Here is some useful info on fast-fail when file is corrupted: https://www.w3.org/TR/png/#13Error-checking
that shouldn't impact performance much |
Included commit with chunk type validation as a proof of concept: 60087bc |
Check chunk types symbol range and whether it's known critical chunk
Again, thanks for your work on this. I was looking for the most optimal way to fail-fast if we don't find the We could, of course, add an extra exported function (or include an optional toggle argument) to let users opt-in for full validation of the file. But that would better suit a new feature branch. For now, I will revert the chunk type validation and create a new branch for that (see here). If we want, we can work on it there. |
This reverts commit 60087bc.
Byte sequence
acTL
can be encountered in other parts of PNG, that are not chunk type (e.g. in chunk data or crc), so we should check only chunk types to avoid false positive detection.