createfromwbmp2.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. //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. Warning: imagecreatefromwbmp(): gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
  41. in %s on line %d
  42. Warning: imagecreatefromwbmp(): '%s' is not a valid WBMP file in %s on line %d