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