Annotation of embedaddon/php/ext/gd/tests/createfromwbmp2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: imagecreatefromwbmp with invalid wbmp
3: --SKIPIF--
4: <?php
5: if (!function_exists('imagecreatefromwbmp')) die("skip gd extension not available\n");
6: if (!GD_BUNDLED) die("skip requires bundled GD library\n");
7: ?>
8: --FILE--
9: <?php
10: $filename = dirname(__FILE__) . '/_tmp.wbmp';
11: $fp = fopen($filename,"wb");
12: if (!$fp) {
13: exit("Failed to create <$filename>");
14: }
15:
16: //write header
17: $c = 0;
18: fputs($fp, chr($c), 1);
19: fputs($fp, $c, 1);
20:
21: //write width = 2^32 / 4 + 1
22: $c = 0x84;
23: fputs($fp, chr($c), 1);
24: $c = 0x80;
25: fputs($fp, chr($c), 1);
26: fputs($fp, chr($c), 1);
27: fputs($fp, chr($c), 1);
28: $c = 0x01;
29: fputs($fp, chr($c), 1);
30:
31: /*write height = 4*/
32: $c = 0x04;
33: fputs($fp, chr($c), 1);
34:
35: /*write some data to cause overflow*/
36: for ($i=0; $i<10000; $i++) {
37: fwrite($fp, chr($c), 1);
38: }
39:
40: fclose($fp);
41: $im = imagecreatefromwbmp($filename);
42: unlink($filename);
43: ?>
44: --EXPECTF--
45: Warning: imagecreatefromwbmp(): gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
46: in %s on line %d
47:
48: Warning: imagecreatefromwbmp(): '%s' is not a valid WBMP file in %s on line %d
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>