bignames_overflow.phpt 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. --TEST--
  2. Phar: tar with huge filenames, buffer overflow
  3. --EXTENSIONS--
  4. phar
  5. --INI--
  6. phar.require_hash=0
  7. --FILE--
  8. <?php
  9. $fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.tar';
  10. $fname2 = __DIR__ . '/' . basename(__FILE__, '.php') . '.2.tar';
  11. $pname = 'phar://' . $fname;
  12. include __DIR__ . '/files/make.dangerous.tar.php.inc';
  13. $tar = new danger_tarmaker($fname, 'none');
  14. $tar->init();
  15. $tar->addFile(str_repeat('a', 101), 'hi');
  16. $tar->addFile(str_repeat('a', 255), 'hi2');
  17. $tar->close();
  18. $p1 = new PharData($fname);
  19. foreach ($p1 as $file) {
  20. echo $file->getFileName(), "\n";
  21. }
  22. echo $p1['a/' . str_repeat('a', 100)]->getContent() . "\n";
  23. echo $p1[str_repeat('a', 155) . '/' . str_repeat('a', 100)]->getContent() . "\n";
  24. ?>
  25. --CLEAN--
  26. <?php
  27. unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.tar');
  28. unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.tar');
  29. ?>
  30. --EXPECT--
  31. a
  32. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  33. hi
  34. hi2