bug77177.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --TEST--
  2. Bug #77177 (Serializing or unserializing COM objects crashes)
  3. --EXTENSIONS--
  4. com_dotnet
  5. --FILE--
  6. <?php
  7. $com = new COM("WScript.Shell");
  8. $dotnet = new DOTNET("mscorlib", "System.Collections.Stack");
  9. $variant = new VARIANT;
  10. foreach ([$com, $dotnet, $variant] as $object) {
  11. try {
  12. serialize($object);
  13. } catch (Exception $ex) {
  14. echo "Exception: {$ex->getMessage()}\n";
  15. }
  16. }
  17. $strings = ['C:3:"com":0:{}', 'C:6:"dotnet":0:{}', 'C:7:"variant":0:{}'];
  18. foreach ($strings as $string) {
  19. try {
  20. unserialize($string);
  21. } catch (Exception $ex) {
  22. echo "Exception: {$ex->getMessage()}\n";
  23. }
  24. }
  25. $strings = ['O:3:"com":0:{}', 'O:6:"dotnet":0:{}', 'O:7:"variant":0:{}'];
  26. foreach ($strings as $string) {
  27. try {
  28. unserialize($string);
  29. } catch (Exception $ex) {
  30. echo "Exception: {$ex->getMessage()}\n";
  31. }
  32. }
  33. ?>
  34. --EXPECTF--
  35. Exception: Serialization of 'com' is not allowed
  36. Exception: Serialization of 'dotnet' is not allowed
  37. Exception: Serialization of 'variant' is not allowed
  38. Exception: Unserialization of 'com' is not allowed
  39. Exception: Unserialization of 'dotnet' is not allowed
  40. Exception: Unserialization of 'variant' is not allowed
  41. Exception: Unserialization of 'com' is not allowed
  42. Exception: Unserialization of 'dotnet' is not allowed
  43. Exception: Unserialization of 'variant' is not allowed