bug72562.phpt 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. --TEST--
  2. Bug #72562: Use After Free in unserialize() with Unexpected Session Deserialization
  3. --SKIPIF--
  4. <?php include('skipif.inc'); ?>
  5. --FILE--
  6. <?php
  7. ini_set('session.serialize_handler', 'php_binary');
  8. session_start();
  9. $sess = "\x1xi:1;\x2y";
  10. session_decode($sess);
  11. $uns_1 = '{';
  12. $out_1[] = unserialize($uns_1);
  13. unset($out_1);
  14. $fakezval = ptr2str(1122334455);
  15. $fakezval .= ptr2str(0);
  16. $fakezval .= "\x00\x00\x00\x00";
  17. $fakezval .= "\x01";
  18. $fakezval .= "\x00";
  19. $fakezval .= "\x00\x00";
  20. for ($i = 0; $i < 5; $i++) {
  21. $v[$i] = $fakezval.$i;
  22. }
  23. $uns_2 = 'R:2;';
  24. $out_2 = unserialize($uns_2);
  25. var_dump($out_2);
  26. function ptr2str($ptr)
  27. {
  28. $out = '';
  29. for ($i = 0; $i < 8; $i++) {
  30. $out .= chr($ptr & 0xff);
  31. $ptr >>= 8;
  32. }
  33. return $out;
  34. }
  35. ?>
  36. --EXPECTF--
  37. Warning: session_decode(): Failed to decode session object. Session has been destroyed in %s%ebug72562.php on line %d
  38. Notice: unserialize(): Error at offset 0 of 1 bytes in %s%ebug72562.php on line %d
  39. Notice: unserialize(): Error at offset 4 of 4 bytes in %s%ebug72562.php on line %d
  40. bool(false)