|
|
b74969 |
Fix for CVE-2017-10168
|
|
|
b74969 |
Backported for 5.4 without test and binary patch
|
|
|
b74969 |
|
|
|
b74969 |
|
|
|
b74969 |
From f1b2afc9d9e77edf41804f5dfc4e2069d8a12975 Mon Sep 17 00:00:00 2001
|
|
|
b74969 |
From: "Christoph M. Becker" <cmbecker69@gmx.de>
|
|
|
b74969 |
Date: Tue, 16 Aug 2016 18:23:36 +0200
|
|
|
b74969 |
Subject: [PATCH] Fix #73868: DOS vulnerability in gdImageCreateFromGd2Ctx()
|
|
|
b74969 |
|
|
|
b74969 |
We must not pretend that there are image data if there are none. Instead
|
|
|
b74969 |
we fail reading the image file gracefully.
|
|
|
b74969 |
|
|
|
b74969 |
(cherry picked from commit cdb648dc4115ce0722f3cc75e6a65115fc0e56ab)
|
|
|
b74969 |
---
|
|
|
b74969 |
ext/gd/libgd/gd_gd2.c | 8 ++++++--
|
|
|
b74969 |
ext/gd/tests/bug73868.gd2 | Bin 0 -> 1050 bytes
|
|
|
b74969 |
ext/gd/tests/bug73868.phpt | 18 ++++++++++++++++++
|
|
|
b74969 |
3 files changed, 24 insertions(+), 2 deletions(-)
|
|
|
b74969 |
create mode 100644 ext/gd/tests/bug73868.gd2
|
|
|
b74969 |
create mode 100644 ext/gd/tests/bug73868.phpt
|
|
|
b74969 |
|
|
|
b74969 |
diff --git a/ext/gd/libgd/gd_gd2.c b/ext/gd/libgd/gd_gd2.c
|
|
|
b74969 |
index d06f328..196b785 100644
|
|
|
b74969 |
--- a/ext/gd/libgd/gd_gd2.c
|
|
|
b74969 |
+++ b/ext/gd/libgd/gd_gd2.c
|
|
|
b74969 |
@@ -334,12 +334,16 @@ gdImagePtr gdImageCreateFromGd2Ctx (gdIOCtxPtr in)
|
|
|
b74969 |
for (x = xlo; x < xhi; x++) {
|
|
|
b74969 |
if (im->trueColor) {
|
|
|
b74969 |
if (!gdGetInt(&im->tpixels[y][x], in)) {
|
|
|
b74969 |
- im->tpixels[y][x] = 0;
|
|
|
b74969 |
+ php_gd_error("gd2: EOF while reading\n");
|
|
|
b74969 |
+ gdImageDestroy(im);
|
|
|
b74969 |
+ return NULL;
|
|
|
b74969 |
}
|
|
|
b74969 |
} else {
|
|
|
b74969 |
int ch;
|
|
|
b74969 |
if (!gdGetByte(&ch, in)) {
|
|
|
b74969 |
- ch = 0;
|
|
|
b74969 |
+ php_gd_error("gd2: EOF while reading\n");
|
|
|
b74969 |
+ gdImageDestroy(im);
|
|
|
b74969 |
+ return NULL;
|
|
|
b74969 |
}
|
|
|
b74969 |
im->pixels[y][x] = ch;
|
|
|
b74969 |
}
|
|
|
b74969 |
--
|
|
|
b74969 |
2.1.4
|
|
|
b74969 |
|