com php-src: Fix #73868: DOS vulnerability in gdImageCreateFromGd2Ctx(): ext/gd/libgd/gd_gd2.c ext/gd/tests/bug73868 .gd2 ext/gd/tests/bug73868.phpt

From: Date: Tue, 17 Jan 2017 20:42:35 +0000
Subject: com php-src: Fix #73868: DOS vulnerability in gdImageCreateFromGd2Ctx(): ext/gd/libgd/gd_gd2.c ext/gd/tests/bug73868 .gd2 ext/gd/tests/bug73868.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-96776@lists.php.net to get a copy of this message
Commit: c95dcc3bb29df76b8656c960dbfd80b0720ffde8 Author: Christoph M. Becker <cmbecker69@gmx.de> Tue, 16 Aug 2016 18:23:36 +0200 Committer: Joe Watkins <krakjoe@php.net> Tue, 17 Jan 2017 20:42:35 +0000 Parents: 84aa9d5e9a325db5fa49b06e49f6e71cf483d661 Branches: PHP-7.1..1 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c95dcc3bb29df76b8656c960dbfd80b0720ffde8 Log: Fix #73868: DOS vulnerability in gdImageCreateFromGd2Ctx() We must not pretend that there are image data if there are none. Instead we fail reading the image file gracefully. (cherry picked from commit cdb648dc4115ce0722f3cc75e6a65115fc0e56ab) Bugs: https://bugs.php.net/73868 Changed paths: M ext/gd/libgd/gd_gd2.c A ext/gd/tests/bug73868.gd2 A ext/gd/tests/bug73868.phpt Diff: diff --git a/ext/gd/libgd/gd_gd2.c b/ext/gd/libgd/gd_gd2.c index d06f328..196b785 100644 --- a/ext/gd/libgd/gd_gd2.c +++ b/ext/gd/libgd/gd_gd2.c @@ -340,12 +340,16 @@ gdImagePtr gdImageCreateFromGd2Ctx (gdIOCtxPtr in) for (x = xlo; x < xhi; x++) { if (im->trueColor) { if (!gdGetInt(&im->tpixels[y][x], in)) { - im->tpixels[y][x] = 0; + php_gd_error("gd2: EOF while reading\n"); + gdImageDestroy(im); + return NULL; } } else { int ch; if (!gdGetByte(&ch, in)) { - ch = 0; + php_gd_error("gd2: EOF while reading\n"); + gdImageDestroy(im); + return NULL; } im->pixels[y][x] = ch; } diff --git a/ext/gd/tests/bug73868.gd2 b/ext/gd/tests/bug73868.gd2 new file mode 100644 index 0000000..1c797d1 Binary files /dev/null and b/ext/gd/tests/bug73868.gd2 differ diff --git a/ext/gd/tests/bug73868.phpt b/ext/gd/tests/bug73868.phpt new file mode 100644 index 0000000..135be79 --- /dev/null +++ b/ext/gd/tests/bug73868.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug 73868 (DOS vulnerability in gdImageCreateFromGd2Ctx()) +--SKIPIF-- +<?php +if (!extension_loaded('gd')) die('skip gd extension not available'); +?> +--FILE-- +<?php +var_dump(imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73868.gd2')); +?> +===DONE=== +--EXPECTF-- +Warning: imagecreatefromgd2(): gd2: EOF while reading + in %s on line %d + +Warning: imagecreatefromgd2(): '%s' is not a valid GD2 file in %s on line %d +bool(false) +===DONE===

« previous php.cvs (#96776) next »