1--TEST-- 2imagecreatefromwbmp 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 extern GD\n"); 7?> 8--FILE-- 9<?php 10$filename = dirname(__FILE__) . '/_tmp.wbmp'; 11$fp = fopen($filename,"wb"); 12if (!$fp) { 13 exit("Failed to create <$filename>"); 14} 15 16//write header 17$c = 0; 18fputs($fp, chr($c), 1); 19fputs($fp, $c, 1); 20 21//write width = 2^32 / 4 + 1 22$c = 0x84; 23fputs($fp, chr($c), 1); 24$c = 0x80; 25fputs($fp, chr($c), 1); 26fputs($fp, chr($c), 1); 27fputs($fp, chr($c), 1); 28$c = 0x01; 29fputs($fp, chr($c), 1); 30 31/*write height = 4*/ 32$c = 0x04; 33fputs($fp, chr($c), 1); 34 35/*write some data to cause overflow*/ 36for ($i=0; $i<10000; $i++) { 37 fwrite($fp, chr($c), 1); 38} 39 40fclose($fp); 41$im = imagecreatefromwbmp($filename); 42unlink($filename); 43?> 44--EXPECTF-- 45gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully 46 47Warning: imagecreatefromwbmp(): '%s_tmp.wbmp' is not a valid WBMP file in %s on line %d 48