bug77177.phpt 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. --TEST--
  2. Bug #77177 (Serializing or unserializing COM objects crashes)
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
  6. ?>
  7. --FILE--
  8. <?php
  9. $com = new COM("WScript.Shell");
  10. $dotnet = new DOTNET("mscorlib", "System.Collections.Stack");
  11. $variant = new VARIANT;
  12. foreach ([$com, $dotnet, $variant] as $object) {
  13. try {
  14. serialize($object);
  15. } catch (Exception $ex) {
  16. echo "Exception: {$ex->getMessage()}\n";
  17. }
  18. }
  19. $strings = ['C:3:"com":0:{}', 'C:6:"dotnet":0:{}', 'C:7:"variant":0:{}'];
  20. foreach ($strings as $string) {
  21. try {
  22. unserialize($string);
  23. } catch (Exception $ex) {
  24. echo "Exception: {$ex->getMessage()}\n";
  25. }
  26. }
  27. $strings = ['O:3:"com":0:{}', 'O:6:"dotnet":0:{}', 'O:7:"variant":0:{}'];
  28. foreach ($strings as $string) {
  29. var_dump(unserialize($string));
  30. }
  31. ?>
  32. ===DONE===
  33. --EXPECTF--
  34. Exception: Serialization of 'com' is not allowed
  35. Exception: Serialization of 'dotnet' is not allowed
  36. Exception: Serialization of 'variant' is not allowed
  37. Exception: Unserialization of 'com' is not allowed
  38. Exception: Unserialization of 'dotnet' is not allowed
  39. Exception: Unserialization of 'variant' is not allowed
  40. Warning: Erroneous data format for unserializing 'com' in %s on line %d
  41. Notice: unserialize(): Error at offset 13 of 14 bytes in %s on line %d
  42. bool(false)
  43. Warning: Erroneous data format for unserializing 'dotnet' in %s on line %d
  44. Notice: unserialize(): Error at offset 16 of 17 bytes in %s on line %d
  45. bool(false)
  46. Warning: Erroneous data format for unserializing 'variant' in %s on line %d
  47. Notice: unserialize(): Error at offset 17 of 18 bytes in %s on line %d
  48. bool(false)
  49. ===DONE===