bug76047.phpt 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. --TEST--
  2. Bug #76047: Use-after-free when accessing already destructed backtrace arguments
  3. --FILE--
  4. <?php
  5. class Vuln {
  6. public $a;
  7. public function __destruct() {
  8. unset($this->a);
  9. $backtrace = (new Exception)->getTrace();
  10. var_dump($backtrace);
  11. }
  12. }
  13. function test($arg) {
  14. $arg = str_shuffle(str_repeat('A', 79));
  15. $vuln = new Vuln();
  16. $vuln->a = $arg;
  17. }
  18. function test2($arg) {
  19. $$arg = 1; // Trigger symbol table
  20. $arg = str_shuffle(str_repeat('A', 79));
  21. $vuln = new Vuln();
  22. $vuln->a = $arg;
  23. }
  24. test('x');
  25. test2('x');
  26. ?>
  27. --EXPECTF--
  28. array(1) {
  29. [0]=>
  30. array(6) {
  31. ["file"]=>
  32. string(%d) "%s"
  33. ["line"]=>
  34. int(%d)
  35. ["function"]=>
  36. string(10) "__destruct"
  37. ["class"]=>
  38. string(4) "Vuln"
  39. ["type"]=>
  40. string(2) "->"
  41. ["args"]=>
  42. array(0) {
  43. }
  44. }
  45. }
  46. array(1) {
  47. [0]=>
  48. array(6) {
  49. ["file"]=>
  50. string(%d) "%s"
  51. ["line"]=>
  52. int(%d)
  53. ["function"]=>
  54. string(10) "__destruct"
  55. ["class"]=>
  56. string(4) "Vuln"
  57. ["type"]=>
  58. string(2) "->"
  59. ["args"]=>
  60. array(0) {
  61. }
  62. }
  63. }