SDL_image PCX loader crashes (patch included)

Hi,

I’ve just discovered and fixed a problem with the current
SDL_image 1.2.3 which can crash on every PCX file with an
image width not being a multiple of 8 pixels if stored in
bitplane format (with 4 or less bitplanes).

In this case, the PCX loader happily writes beyond the
allocated bitmap data buffer of the image surface in each
line, which ends with a Segmentation Fault in the last
line if you have bad luck and your allocated memory page
ends near the last byte of the bitmap data. (In most cases
you may have luck, which made this crash very difficult to
track down in my case.)

As this error is not fixed in the CVS yet, I’ve attached a
patch to fix this bug (three lines in “IMG_pcx.c”). The fix
prevents reading/writing the memory beyond the current line
of the image being loaded.

This was a particularly nasty error for me, because all my
image files have a width which is a multiple of 8 or even
16/32, so the error never showed up, but some people creating
custom artwork for my game Rocks’n’Diamonds created images
less “perfect” :wink: and the game crashed on those image files
only from time to time.

Hope the fix finds its way into the official SDL_image soon
for all people building my games from source. (The Windows
folk get their pre-build, fixed version of “SDL_image.dll”.)

Best regards,
Holger–
holger.schemel at telefonica.de

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…
Name: IMG_pcx.c.diff
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20030804/54201fc7/attachment.txt

Hi,

I’ve just discovered and fixed a problem with the current
SDL_image 1.2.3 which can crash on every PCX file with an
image width not being a multiple of 8 pixels if stored in
bitplane format (with 4 or less bitplanes).

Thanks! I’ve applied your patch to CVS.

See ya!
-Sam Lantinga, Software Engineer, Blizzard Entertainment