com php-src: Fix #73155: imagegd2() writes wrong chunk sizes on boundaries: NEWS ext/gd/libgd/gd_gd2.c ext/gd/tests/bug7315 5.phpt

From: Date: Sat, 24 Sep 2016 08:33:49 +0000
Subject: com php-src: Fix #73155: imagegd2() writes wrong chunk sizes on boundaries: NEWS ext/gd/libgd/gd_gd2.c ext/gd/tests/bug7315 5.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-94676@lists.php.net to get a copy of this message
Commit: c7936ead8fbe87a55e7c17f9449c2704acd810a3 Author: Christoph M. Becker <cmbecker69@gmx.de> Sat, 24 Sep 2016 00:46:35 +0200 Parents: 1da79a6c6e39f08a91c2e3ae9281c1b0e5261510 Branches: PHP-5.6 PHP-7..0 PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c7936ead8fbe87a55e7c17f9449c2704acd810a3 Log: Fix #73155: imagegd2() writes wrong chunk sizes on boundaries Bugs: https://bugs.php.net/73155 Changed paths: M NEWS M ext/gd/libgd/gd_gd2.c A ext/gd/tests/bug73155.phpt Diff: diff --git a/NEWS b/NEWS index b9ef512..c0cefba 100644 --- a/NEWS +++ b/NEWS @@ -27,6 +27,7 @@ PHP NEWS . Fixed bug #53504 (imagettfbbox gives incorrect values for bounding box). (Mark Plomer, cmb) . Fixed bug #73157 (imagegd2() ignores 3rd param if 4 are given). (cmb) + . Fixed bug #73155 (imagegd2() writes wrong chunk sizes on boundaries). (cmb) - Mbstring: . Fixed bug #72994 (mbc_to_code() out of bounds read). (Laruence, cmb) diff --git a/ext/gd/libgd/gd_gd2.c b/ext/gd/libgd/gd_gd2.c index e954aaf..3b4dfbe 100644 --- a/ext/gd/libgd/gd_gd2.c +++ b/ext/gd/libgd/gd_gd2.c @@ -689,8 +689,8 @@ static void _gdImageGd2 (gdImagePtr im, gdIOCtx * out, int cs, int fmt) } /* Work out number of chunks. */ - ncx = im->sx / cs + 1; - ncy = im->sy / cs + 1; + ncx = (im->sx + cs - 1) / cs; + ncy = (im->sy + cs - 1) / cs; /* Write the standard header. */ _gd2PutHeader (im, out, cs, fmt, ncx, ncy); diff --git a/ext/gd/tests/bug73155.phpt b/ext/gd/tests/bug73155.phpt new file mode 100644 index 0000000..dc1791e --- /dev/null +++ b/ext/gd/tests/bug73155.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #73155 (imagegd2() writes wrong chunk sizes on boundaries) +--SKIPIF-- +<?php +if (!extension_loaded('gd')) die('skip gd extension not available'); +?> +--FILE-- +<?php +$im = imagecreate(64, 64); +imagecolorallocate($im, 0, 0, 0); + +ob_start(); +imagegd2($im, null, 64, IMG_GD2_RAW); +$buffer = ob_get_clean(); + +$header = unpack('@10/nchunk_size/nformat/nx_count/ny_count', $buffer); +printf("chunk size: %d\n", $header['chunk_size']); +printf("x chunk count: %d\n", $header['x_count']); +printf("y chunk count: %d\n", $header['y_count']); +printf("file size: %d\n", strlen($buffer)); +?> +===DONE=== +--EXPECT-- +chunk size: 64 +x chunk count: 1 +y chunk count: 1 +file size: 5145 +===DONE===

« previous php.cvs (#94676) next »