Menu ▾ ▴

#271 PCX file conversion crash on special files

None
closed
None
5
2018-07-31
2017-01-19
No

When loading the attached PCX file, freeimage crashes with an access violation.

1 Attachments

Discussion

  • Jojakim Stahl

    Jojakim Stahl - 2017-01-19

    The problem is with PCX file with 1 plane and 1 or 8 bpp on the plane and a header value of bytes_per_line greater than (width from window) * bpp / 8. I tried to read this file with several other programs (gimp for examble) without any problems.

    So I researched the problem:
    The scanline is read directly into the dib buffer. However the dib is created with a width corresponding to the width of the window header field. If bytes_per_line doesn't correspond exactly to this, too many bytes are copied to the dib buffer.
    I first tried to just read the amount of bytes expected by the dib and leave up the rest to be discarded by the existing for loop, but the loop doesn't handle RLE compression correctly.
    So I do not know why at all this loop is there - in my opinion it is a copy paste leftover - but I didn't touch it.
    My fix now is to read the line into a temp buffer, like it is done with other plane / bpp combinations and then copy the needed bytes over to the dib.
    See attached patch.

     

    Last edit: Jojakim Stahl 2017-01-19
  • Hervé Drolon

    Hervé Drolon - 2017-01-21
    • status: open --> pending
    • assigned_to: Hervé Drolon
    • Group: -->
     
  • Hervé Drolon

    Hervé Drolon - 2017-01-21

    Hi Jojakim,

    Thanks for the bug fix, it is now available in the CVS.

    However, this is a "quick and dirty" fix. The PCX format is a very old (and very badly designed) format, and the FreeImage PCX plugin is also very old.
    A complete refactoring would be needed, but it's not the priority, as this very bad format should disappear from user's customer databases and should be replaced by the PNG format.
    I just hope that you will be able to convert all your images to PNG easily.

    Hervé

     
  • Hervé Drolon

    Hervé Drolon - 2018-07-31
    • status: pending --> closed
     
  • Hervé Drolon

    Hervé Drolon - 2018-07-31

    Fixed in release 3.18.0

     

Log in to post a comment.