bug79091.phpt 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. --TEST--
  2. Bug #79091 (heap use-after-free in session_create_id())
  3. --EXTENSIONS--
  4. session
  5. --FILE--
  6. <?php
  7. class MySessionHandler implements SessionHandlerInterface, SessionIdInterface, SessionUpdateTimestampHandlerInterface
  8. {
  9. public function close(): bool
  10. {
  11. return true;
  12. }
  13. public function destroy($session_id): bool
  14. {
  15. return true;
  16. }
  17. public function gc($maxlifetime): int|false
  18. {
  19. return true;
  20. }
  21. public function open($save_path, $session_name): bool
  22. {
  23. return true;
  24. }
  25. public function read($session_id): string|false
  26. {
  27. return '';
  28. }
  29. public function write($session_id, $session_data): bool
  30. {
  31. return true;
  32. }
  33. public function create_sid(): string
  34. {
  35. return uniqid();
  36. }
  37. public function updateTimestamp($key, $val): bool
  38. {
  39. return true;
  40. }
  41. public function validateId($key): bool
  42. {
  43. return true;
  44. }
  45. }
  46. ob_start();
  47. var_dump(session_set_save_handler(new MySessionHandler()));
  48. var_dump(session_start());
  49. ob_flush();
  50. session_create_id();
  51. ?>
  52. --EXPECTF--
  53. bool(true)
  54. bool(true)
  55. Warning: session_create_id(): Failed to create new ID in %s on line %d