createfromwbmp2.phpt 1002 B

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