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

memory leak bug in meta.c: parse8BIM() function #1190

Closed
3 tasks done
fisher2020 opened this issue Jul 3, 2018 · 3 comments
Closed
3 tasks done

memory leak bug in meta.c: parse8BIM() function #1190

fisher2020 opened this issue Jul 3, 2018 · 3 comments
Labels

Comments

@fisher2020
Copy link

fisher2020 commented Jul 3, 2018

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am using the latest version of ImageMagick
  • I have searched open and closed issues to ensure it has not already been reported

Description

hello,i find a memory leak bug in imagemagick,the details is on the Steps to Reproduce.

Steps to Reproduce

the bug located in meta.c ,static ssize_t parse8BIM(Image *ifile, Image *ofile) function
the bug code is on
https://github.com/ImageMagick/ImageMagick/blob/master/coders/meta.c#L327
the code fragment is as follows:

  line = (char *) AcquireQuantumMemory((size_t) inputlen,sizeof(*line)); //llocate a memory and assigned it to line
  if (line == (char *) NULL)
    return(-1);
  newstr = name = token = (char *) NULL;
  savedpos = 0;
  token_info=AcquireTokenInfo();

we can see that we allocate a memory and assigned it to line,but we forget to free it in the code:
https://github.com/ImageMagick/ImageMagick/blob/master/coders/meta.c#L436
the code is as follows:

                if (savedolen > 0)
                  {
                    MagickOffsetType
                      offset;

                    ssize_t diff = outputlen - savedolen;
                    currentpos = TellBlob(ofile);
                    if (currentpos < 0)
                      return(-1);   // return without free line pointed memory
                    offset=SeekBlob(ofile,savedpos,SEEK_SET);
                    if (offset < 0)
                      return(-1);  // return without free line pointed memory
                    (void) WriteBlobMSBLong(ofile,(unsigned int) diff);
                    offset=SeekBlob(ofile,currentpos,SEEK_SET);
                    if (offset < 0)
                      return(-1);
                    savedolen = 0L;
                  }

credit:www.vackbot.com(墨云科技)

urban-warrior pushed a commit to ImageMagick/ImageMagick6 that referenced this issue Jul 4, 2018
@urban-warrior
Copy link
Contributor

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.

@fisher2020
Copy link
Author

@urban-warrior ,will this bug be assigned a cve?

@nohmask
Copy link

nohmask commented Jul 20, 2018

This was assigned CVE-2018-14437.

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