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

CPU exhaustion in ReadOneJNGImage #526

Closed
jgj212 opened this issue Jun 24, 2017 · 6 comments
Closed

CPU exhaustion in ReadOneJNGImage #526

jgj212 opened this issue Jun 24, 2017 · 6 comments
Labels

Comments

@jgj212
Copy link
Contributor

jgj212 commented Jun 24, 2017

Version: ImageMagick 7.0.6-1 Q16 x86_64

$magick identify $FILE

Here is the critical code

        for (i=0; i < (ssize_t) length; i++)   //line 4383
          chunk[i]=(unsigned char) ReadBlobByte(image);

length can be controlled as follow:

    length=ReadBlobMSBLong(image); //4362

length is 32bit, so the loop can be very large, and cause a lot of failed I/O

testcase:
https://github.com/jgj212/poc/blob/master/cpu-jng

Credit: ADLab of Venustech

@mikayla-grace
Copy link

Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ http://www.imagemagick.org/download/beta/ by sometime tomorrow.

@msmeissn
Copy link

i dont see this fixing it.

did you want to add
if (c == EOF) break;
in those loops too?

@urban-warrior
Copy link
Contributor

Which loops? We added checks for EOF in several loops. Did we miss one?

@dlemstra
Copy link
Member

@msmeissn This was fixed in a separate commit de0d686 (im7) and 46e3aab (im6).

@msmeissn
Copy link

thank you :)

@pgajdos
Copy link

pgajdos commented Jan 10, 2018

@jgj212, could you please readd the testcase to your repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

6 participants