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
fisher2020 opened this Issue Jul 3, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@fisher2020

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 that referenced this issue Jul 4, 2018

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

@urban-warrior

This comment has been minimized.

Show comment
Hide comment
@urban-warrior

urban-warrior Jul 4, 2018

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.

Contributor

urban-warrior commented Jul 4, 2018

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

This comment has been minimized.

Show comment
Hide comment
@fisher2020

fisher2020 Jul 5, 2018

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

fisher2020 commented Jul 5, 2018

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

@dlemstra dlemstra added the bug label Jul 8, 2018

@nohmask

This comment has been minimized.

Show comment
Hide comment
@nohmask

nohmask Jul 20, 2018

This was assigned CVE-2018-14437.

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