com php-src: Fix bug #72730 - imagegammacorrect allows arbitrary write access: ext/gd/gd.c ext/gd/tests/bug72730.phpt
| From: | Ferenc Kovacs | Date: | Thu, 18 Aug 2016 10:52:29 +0000 |
| Subject: | com php-src: Fix bug #72730 - imagegammacorrect allows arbitrary write access: ext/gd/gd.c ext/gd/tests/bug72730.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-93963@lists.php.net to get a copy of this message | ||
Commit: 229782c0ada4d7e72dba6327cc7dff889ce7d92f
Author: Stanislav Malyshev <stas@php.net> Wed, 10 Aug 2016 00:14:58 -0700
Committer: Ferenc Kovacs <tyra3l@gmail.com> Thu, 18 Aug 2016 12:52:29 +0200
Parents: 4d76676101f8814520ea988e42b3bda54eb9e255
Branches: PHP-5.6.25
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=229782c0ada4d7e72dba6327cc7dff889ce7d92f
Log:
Fix bug #72730 - imagegammacorrect allows arbitrary write access
Bugs:
https://bugs.php.net/72730
Changed paths:
M ext/gd/gd.c
A ext/gd/tests/bug72730.phpt
Diff:
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index 5c604b7...0fb9604 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -3082,6 +3082,11 @@ PHP_FUNCTION(imagegammacorrect)
return;
}
+ if ( input <= 0.0 || output <= 0.0 ) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Gamma values should be positive");
+ RETURN_FALSE;
+ }
+
ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
if (gdImageTrueColor(im)) {
diff --git a/ext/gd/tests/bug72730.phpt b/ext/gd/tests/bug72730.phpt
new file mode 100644
index 0000000..e7c13cb
--- /dev/null
+++ b/ext/gd/tests/bug72730.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #72730: imagegammacorrect allows arbitrary write access
+--SKIPIF--
+<?php
+if (!function_exists("imagecreatetruecolor")) die("skip");
+?>
+--FILE--
+<?php
+$img = imagecreatetruecolor(1, 1);
+imagegammacorrect($img, -1, 1337);
+?>
+DONE
+--EXPECTF--
+Warning: imagegammacorrect(): Gamma values should be positive in %sbug72730.php on line %d
+DONE
\ No newline at end of file