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

Null Pointer Dereference triggered by malformed Image File #716

Closed
kirit1193 opened this issue Aug 31, 2017 · 2 comments
Closed

Null Pointer Dereference triggered by malformed Image File #716

kirit1193 opened this issue Aug 31, 2017 · 2 comments
Labels

Comments

@kirit1193
Copy link

A Null Pointer Dereference issue is present in the AcquireQuantumMemory function in the file ImageMagick/MagickCore/memory.c. This is due to the following vulnerable code:

if (n != 0)
   {
   dasharray=(double *) AcquireQuantumMemory((size_t) n+1UL,
   sizeof(*dasharray));
   p=CurrentContext->dash_pattern;
   q=dasharray;
   for (i=0; i < (ssize_t) n; i++)
      *q++=(*p++);
   *q=0.0;
   }

The variable dasharray gets the output of AcquireQuantumMemory. Looking at the code within this function, the following code explicitly returns NULL:

if (HeapOverflowSanityCheck(count,quantum) != MagickFalse)
   return((void *) NULL);

Eventually q gets the value stored in dasharray (which is potentially NULL) in q=dasharray;

Finally, q gets explicitly dereferenced in *q++=(*p++);

Using

if (q != NULL)
   *q++=(*p++);

would resolve the Null Pointer Dereference vulnerability.

@urban-warrior
Copy link
Member

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 @ https://www.imagemagick.org/download/beta/ by sometime tomorrow.

@fgeek
Copy link

fgeek commented Sep 18, 2017

https://nvd.nist.gov/vuln/detail/CVE-2017-14505

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

4 participants