mirror of
https://github.com/php/php-src.git
synced 2025-08-19 08:49:28 +02:00
fix segfault in openssl_seal(), add test
This commit is contained in:
parent
f53f3b01dd
commit
2229e563e4
2 changed files with 47 additions and 0 deletions
|
@ -3041,7 +3041,9 @@ PHP_FUNCTION(openssl_seal)
|
||||||
pkeys = safe_emalloc(nkeys, sizeof(*pkeys), 0);
|
pkeys = safe_emalloc(nkeys, sizeof(*pkeys), 0);
|
||||||
eksl = safe_emalloc(nkeys, sizeof(*eksl), 0);
|
eksl = safe_emalloc(nkeys, sizeof(*eksl), 0);
|
||||||
eks = safe_emalloc(nkeys, sizeof(*eks), 0);
|
eks = safe_emalloc(nkeys, sizeof(*eks), 0);
|
||||||
|
memset(eks, 0, sizeof(*eks) * nkeys);
|
||||||
key_resources = safe_emalloc(nkeys, sizeof(long), 0);
|
key_resources = safe_emalloc(nkeys, sizeof(long), 0);
|
||||||
|
memset(key_resources, 0, sizeof(*key_resources) * nkeys);
|
||||||
|
|
||||||
/* get the public keys we are using to seal this data */
|
/* get the public keys we are using to seal this data */
|
||||||
zend_hash_internal_pointer_reset_ex(pubkeysht, &pos);
|
zend_hash_internal_pointer_reset_ex(pubkeysht, &pos);
|
||||||
|
|
45
ext/openssl/tests/002.phpt
Normal file
45
ext/openssl/tests/002.phpt
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
--TEST--
|
||||||
|
openssl_seal() tests
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded("openssl")) print "skip"; ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$a = 1;
|
||||||
|
$b = array(1);
|
||||||
|
$c = array(1);
|
||||||
|
$d = array(1);
|
||||||
|
|
||||||
|
var_dump(openssl_seal($a, $b, $c, $d));
|
||||||
|
var_dump(openssl_seal($a, $a, $a, array()));
|
||||||
|
var_dump(openssl_seal($c, $c, $c, 1));
|
||||||
|
var_dump(openssl_seal($b, $b, $b, ""));
|
||||||
|
|
||||||
|
echo "Done\n";
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Warning: openssl_seal(): not a public key (0th member of pubkeys) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: openssl_seal(): Fourth argument to openssl_seal() must be a non-empty array in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: openssl_seal() expects parameter 1 to be string, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: openssl_seal() expects parameter 1 to be string, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
Done
|
||||||
|
--UEXPECTF--
|
||||||
|
Warning: openssl_seal(): not a public key (0th member of pubkeys) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: openssl_seal(): Fourth argument to openssl_seal() must be a non-empty array in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: openssl_seal() expects parameter 1 to be binary string, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: openssl_seal() expects parameter 1 to be binary string, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
Done
|
Loading…
Add table
Add a link
Reference in a new issue