imagejpeg_nullbyte_injection.phpt 467 B

12345678910111213141516171819202122
  1. --TEST--
  2. Testing null byte injection in imagejpeg
  3. --EXTENSIONS--
  4. gd
  5. --SKIPIF--
  6. <?php
  7. $support = gd_info();
  8. if (!isset($support['JPEG Support']) || $support['JPEG Support'] === false) {
  9. print 'skip jpeg support not available';
  10. }
  11. ?>
  12. --FILE--
  13. <?php
  14. $image = imagecreate(1,1);// 1px image
  15. try {
  16. imagejpeg($image, "./foo\0bar");
  17. } catch (TypeError $e) {
  18. echo $e->getMessage(), "\n";
  19. }
  20. ?>
  21. --EXPECT--
  22. imagejpeg(): Argument #2 ($file) must not contain null bytes