createfromwbmp2_extern.phpt 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 extern GD\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. //write header
  16. $c = 0;
  17. fputs($fp, chr($c), 1);
  18. fputs($fp, $c, 1);
  19. //write width = 2^32 / 4 + 1
  20. $c = 0x84;
  21. fputs($fp, chr($c), 1);
  22. $c = 0x80;
  23. fputs($fp, chr($c), 1);
  24. fputs($fp, chr($c), 1);
  25. fputs($fp, chr($c), 1);
  26. $c = 0x01;
  27. fputs($fp, chr($c), 1);
  28. /*write height = 4*/
  29. $c = 0x04;
  30. fputs($fp, chr($c), 1);
  31. /*write some data to cause overflow*/
  32. for ($i=0; $i<10000; $i++) {
  33. fwrite($fp, chr($c), 1);
  34. }
  35. fclose($fp);
  36. $im = imagecreatefromwbmp($filename);
  37. unlink($filename);
  38. ?>
  39. --EXPECTF--
  40. gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
  41. Warning: imagecreatefromwbmp(): '%s_tmp.wbmp' is not a valid WBMP file in %s on line %d