[gimp/gimp-2-8] PCX: Avoid segmentation fault with invalid file.
- From: Michael Schumacher <schumaml src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-8] PCX: Avoid segmentation fault with invalid file.
- Date: Tue, 11 Apr 2017 19:37:45 +0000 (UTC)
commit c50f0a90e300a543dbbb11c5efcedf3f563698d0
Author: Tobias Stoeckmann <tobias stoeckmann org>
Date: Thu Apr 6 21:37:50 2017 +0200
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>
(cherry picked from commit 10f12bdcbd475b215a4d98a0db21c98debf872d5)
plug-ins/common/file-pcx.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/plug-ins/common/file-pcx.c b/plug-ins/common/file-pcx.c
index 09f737e..6c7c83f 100644
--- a/plug-ins/common/file-pcx.c
+++ b/plug-ins/common/file-pcx.c
@@ -405,7 +405,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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]