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

Inflation algorithm used for decoding can go into infinite loop #70

Open
tommy2is opened this issue Sep 20, 2021 · 2 comments
Open

Inflation algorithm used for decoding can go into infinite loop #70

tommy2is opened this issue Sep 20, 2021 · 2 comments

Comments

@tommy2is
Copy link

tommy2is commented Sep 20, 2021

Issue: Application hangs while attempting to decode image from the internet.

Expected: Should be able to handle any input, throws error if input is invalid

Details: My application would hang on line 237 - in the decoded loop below

             while (!0) {
                var T = v[e(N, d) & X];
                d += T & 15;
                var p = T >>> 4;
                if (p >>> 8 == 0) {
                    W[w++] = p;
                } else if (p == 256) {
                    break;
                } else {
                  ......
                }
            }

I'm not sure what the above does, other than the fact that it's part of zlib. However, X would be 0, d would change, but T is 3 and p is always 0, and it enters an infinite loop.

@photopea
Copy link
Owner

Hi, sorry, we can guarantee a correct functinality only on valid PNG images. If your image is invalid, we can not guarantee any meaningful behaviour :(

Maybe you can make your fork of UPNG.js and replace our inflater with pako.js , which can throw errors when there are errors.

@photopea
Copy link
Owner

Or is it a valid PNG? Could you share it with us?

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