Skip to content

Commit

Permalink
Fix bug #72730 - imagegammacorrect allows arbitrary write access
Browse files Browse the repository at this point in the history
  • Loading branch information
smalyshev committed Aug 17, 2016
1 parent a3598dd commit 1bd103d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ext/gd/gd.c
Expand Up @@ -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)) {
Expand Down
15 changes: 15 additions & 0 deletions 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

0 comments on commit 1bd103d

Please sign in to comment.