xref: /PHP-7.1/ext/openssl/tests/bug38255.phpt (revision 7af945e2)
1--TEST--
2openssl key from zval leaks
3--SKIPIF--
4<?php
5if (!extension_loaded("openssl")) die("skip");
6?>
7--FILE--
8<?php
9$pub_key_id = false;
10$signature = '';
11$ok = openssl_verify("foo", $signature, $pub_key_id, OPENSSL_ALGO_MD5);
12
13class test {
14    function __toString() {
15        return "test object";
16    }
17}
18$t = new test;
19
20
21var_dump(openssl_verify("foo", $signature, $pub_key_id, OPENSSL_ALGO_MD5));
22var_dump(openssl_verify("foo", $t, $pub_key_id, OPENSSL_ALGO_MD5));
23var_dump(openssl_verify("foo", new stdClass, $pub_key_id, OPENSSL_ALGO_MD5));
24var_dump(openssl_verify("foo", new stdClass, array(), OPENSSL_ALGO_MD5));
25var_dump(openssl_verify("foo", array(), array(), OPENSSL_ALGO_MD5));
26var_dump(openssl_verify());
27var_dump(openssl_verify(new stdClass, new stdClass, array(), 10000));
28
29echo "Done\n";
30
31?>
32--EXPECTF--
33Warning: openssl_verify(): supplied key param cannot be coerced into a public key in %s on line %d
34
35Warning: openssl_verify(): supplied key param cannot be coerced into a public key in %s on line %d
36bool(false)
37
38Warning: openssl_verify(): supplied key param cannot be coerced into a public key in %s on line %d
39bool(false)
40
41Warning: openssl_verify() expects parameter 2 to be string, object given in %s on line %d
42NULL
43
44Warning: openssl_verify() expects parameter 2 to be string, object given in %s on line %d
45NULL
46
47Warning: openssl_verify() expects parameter 2 to be string, array given in %s on line %d
48NULL
49
50Warning: openssl_verify() expects at least 3 parameters, 0 given in %s on line %d
51NULL
52
53Warning: openssl_verify() expects parameter 1 to be string, object given in %s on line %d
54NULL
55Done
56