diff options
author | Pierre Joye <pajoye@php.net> | 2008-07-17 23:13:09 +0000 |
---|---|---|
committer | Pierre Joye <pajoye@php.net> | 2008-07-17 23:13:09 +0000 |
commit | 9a60aed6d1925c98b1b40c19b40f5b4b65baa26e (patch) | |
tree | 660144bf686964ec1663d09aa87e69096733becb /ext/gd/tests/imageloadfont_invalid.phpt | |
parent | 2392861770c5a540f2cd1fe340f62c2789c3d33f (diff) | |
download | php-git-9a60aed6d1925c98b1b40c19b40f5b4b65baa26e.tar.gz |
- MFB: fix crash when some crafted font are given
Diffstat (limited to 'ext/gd/tests/imageloadfont_invalid.phpt')
-rw-r--r-- | ext/gd/tests/imageloadfont_invalid.phpt | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ext/gd/tests/imageloadfont_invalid.phpt b/ext/gd/tests/imageloadfont_invalid.phpt new file mode 100644 index 0000000000..b297ac73e2 --- /dev/null +++ b/ext/gd/tests/imageloadfont_invalid.phpt @@ -0,0 +1,25 @@ +--TEST-- +imageloadfont() function crashes +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); + if (!GD_BUNDLED) die('skip external GD libraries always fail'); +?> +--FILE-- +<?php +$filename = dirname(__FILE__) . '/font.gdf'; +$bin = "\x41\x41\x41\x41\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00"; +$fp = fopen($filename, 'wb'); +fwrite($fp, $bin); +fclose($fp); + +$image = imagecreatetruecolor(50, 20); +$font = imageloadfont($filename); +$black = imagecolorallocate($image, 0, 0, 0); +imagestring($image, $font, 0, 0, "Hello", $black); +?> +--EXPECTF-- +Warning: imageloadfont(): gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully + in %simageloadfont_invalid.php on line %d + +Warning: imageloadfont(): Error reading font, invalid font header in %simageloadfont_invalid.php on line %d |