createfromwbmp2_extern.phpt 963 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --TEST--
  2. imagecreatefromwbmp with invalid wbmp
  3. --EXTENSIONS--
  4. gd
  5. --SKIPIF--
  6. <?php
  7. if (GD_BUNDLED) die("skip requires extern GD\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. gd warning: Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
  42. Warning: imagecreatefromwbmp(): "%s_tmp.wbmp" is not a valid WBMP file in %s on line %d