SplObjectStorage_unserialize_bad.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --TEST--
  2. SPL: Test that serialized blob contains unique elements (CVE-2010-2225)
  3. --FILE--
  4. <?php
  5. $badblobs = array(
  6. 'x:i:2;i:0;,i:1;;i:0;,i:2;;m:a:0:{}',
  7. 'x:i:3;O:8:"stdClass":0:{},O:8:"stdClass":0:{};R:2;,i:1;;O:8:"stdClass":0:{},r:2;;m:a:0:{}',
  8. 'x:i:3;O:8:"stdClass":0:{},O:8:"stdClass":0:{};r:2;,i:1;;O:8:"stdClass":0:{},r:2;;m:a:0:{}',
  9. 'x:i:1;O:8:"stdClass":0:{},N;;m:s:40:"1234567890123456789012345678901234567890"',
  10. );
  11. foreach($badblobs as $blob) {
  12. try {
  13. $so = new SplObjectStorage();
  14. $so->unserialize($blob);
  15. var_dump($so);
  16. } catch(UnexpectedValueException $e) {
  17. echo $e->getMessage()."\n";
  18. }
  19. }
  20. echo "DONE\n";
  21. --EXPECTF--
  22. Error at offset 6 of 34 bytes
  23. Error at offset 46 of 89 bytes
  24. object(SplObjectStorage)#2 (1) {
  25. ["storage":"SplObjectStorage":private]=>
  26. array(2) {
  27. ["%s"]=>
  28. array(2) {
  29. ["obj"]=>
  30. object(stdClass)#3 (0) {
  31. }
  32. ["inf"]=>
  33. int(1)
  34. }
  35. ["%s"]=>
  36. array(2) {
  37. ["obj"]=>
  38. object(stdClass)#1 (0) {
  39. }
  40. ["inf"]=>
  41. object(stdClass)#3 (0) {
  42. }
  43. }
  44. }
  45. }
  46. Error at offset 78 of 78 bytes
  47. DONE