bug66356.phpt 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. --TEST--
  2. Bug #66356 (Heap Overflow Vulnerability in imagecrop())
  3. --EXTENSIONS--
  4. gd
  5. --FILE--
  6. <?php
  7. $img = imagecreatetruecolor(10, 10);
  8. // POC #1
  9. var_dump(imagecrop($img, array("x" => "a", "y" => 0, "width" => 10, "height" => 10)));
  10. $arr = array("x" => "a", "y" => "12b", "width" => 10, "height" => 10);
  11. var_dump(imagecrop($img, $arr));
  12. print_r($arr);
  13. // POC #2
  14. var_dump(imagecrop($img, array("x" => 0, "y" => 0, "width" => -1, "height" => 10)));
  15. // POC #3
  16. var_dump(imagecrop($img, array("x" => -20, "y" => -20, "width" => 10, "height" => 10)));
  17. // POC #4
  18. var_dump(imagecrop($img, array("x" => 0x7fffff00, "y" => 0, "width" => 10, "height" => 10)));
  19. // bug 66815
  20. var_dump(imagecrop($img, array("x" => 0, "y" => 0, "width" => 65535, "height" => 65535)));
  21. ?>
  22. --EXPECTF--
  23. object(GdImage)#2 (0) {
  24. }
  25. object(GdImage)#2 (0) {
  26. }
  27. Array
  28. (
  29. [x] => a
  30. [y] => 12b
  31. [width] => 10
  32. [height] => 10
  33. )
  34. Warning: imagecrop(): One parameter to a memory allocation multiplication is negative or zero, failing operation gracefully
  35. in %s on line %d
  36. bool(false)
  37. object(GdImage)#2 (0) {
  38. }
  39. object(GdImage)#2 (0) {
  40. }
  41. Warning: imagecrop(): Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
  42. in %s on line %d
  43. bool(false)