summaryrefslogtreecommitdiff
path: root/ext/com_dotnet/tests/bug77177.phpt
blob: 901358248c340c23d7cc405cad03595ff62d102a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
--TEST--
Bug #77177 (Serializing or unserializing COM objects crashes)
--SKIPIF--
<?php
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
?>
--FILE--
<?php
$com = new COM("WScript.Shell");
$dotnet = new DOTNET("mscorlib", "System.Collections.Stack");
$variant = new VARIANT;
foreach ([$com, $dotnet, $variant] as $object) {
    try {
        serialize($object);
    } catch (Exception $ex) {
        echo "Exception: {$ex->getMessage()}\n";
    }
}

$strings = ['C:3:"com":0:{}', 'C:6:"dotnet":0:{}', 'C:7:"variant":0:{}'];
foreach ($strings as $string) {
    try {
        unserialize($string);
    } catch (Exception $ex) {
        echo "Exception: {$ex->getMessage()}\n";
    }
}

$strings = ['O:3:"com":0:{}', 'O:6:"dotnet":0:{}', 'O:7:"variant":0:{}'];
foreach ($strings as $string) {
    var_dump(unserialize($string));
}
?>
===DONE===
--EXPECTF--
Exception: Serialization of 'com' is not allowed
Exception: Serialization of 'dotnet' is not allowed
Exception: Serialization of 'variant' is not allowed
Exception: Unserialization of 'com' is not allowed
Exception: Unserialization of 'dotnet' is not allowed
Exception: Unserialization of 'variant' is not allowed

Warning: Erroneous data format for unserializing 'com' in %s on line %d

Notice: unserialize(): Error at offset 13 of 14 bytes in %s on line %d
bool(false)

Warning: Erroneous data format for unserializing 'dotnet' in %s on line %d

Notice: unserialize(): Error at offset 16 of 17 bytes in %s on line %d
bool(false)

Warning: Erroneous data format for unserializing 'variant' in %s on line %d

Notice: unserialize(): Error at offset 17 of 18 bytes in %s on line %d
bool(false)
===DONE===