mirror of https://github.com/GNOME/gimp.git
PCX: Avoid segmentation fault with invalid file.
If a PCX file contains a bytesperline entry which is too small, it is possible to trigger an out of boundary read, which can lead to a segmentation fault. The bytesperline validation is incomplete. While checking if enough bytes per line exist, the integer truncation during the division must be taken into account. An example would be a 1x1 PCX file with a bpp of 1 (monochrome). The current check allows a bytesperline field of 0, which in turn would lead to a 0 byte allocation in load_1. Yet, the code would access index 0. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
This commit is contained in:
parent
5255d91032
commit
10f12bdcbd
|
@ -409,7 +409,7 @@ load_image (const gchar *filename,
|
|||
fclose (fd);
|
||||
return -1;
|
||||
}
|
||||
if (bytesperline < (width * pcx_header.bpp) / 8)
|
||||
if (bytesperline < ((width * pcx_header.bpp + 7) / 8))
|
||||
{
|
||||
g_message (_("Invalid number of bytes per line in PCX header"));
|
||||
fclose (fd);
|
||||
|
|
Loading…
Reference in New Issue