diff options
author | Antony Dovgal <tony2001@php.net> | 2006-08-30 20:50:04 +0000 |
---|---|---|
committer | Antony Dovgal <tony2001@php.net> | 2006-08-30 20:50:04 +0000 |
commit | 1f138e7e017bd765ab0b6c3841453e656b52f1a5 (patch) | |
tree | 791d334462865fc65a24ff2d31af74e7a00af7b2 | |
parent | 26db0920d3e92e4cde582e6ba35bc5747bdde4c0 (diff) | |
download | php-git-1f138e7e017bd765ab0b6c3841453e656b52f1a5.tar.gz |
MFH: fix segfault in openssl_seal(), add test
-rw-r--r-- | ext/openssl/openssl.c | 2 | ||||
-rw-r--r-- | ext/openssl/tests/002.phpt | 32 |
2 files changed, 34 insertions, 0 deletions
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 3c230a5f7e..dc22923814 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -3183,7 +3183,9 @@ PHP_FUNCTION(openssl_seal) pkeys = safe_emalloc(nkeys, sizeof(*pkeys), 0); eksl = safe_emalloc(nkeys, sizeof(*eksl), 0); eks = safe_emalloc(nkeys, sizeof(*eks), 0); + memset(eks, 0, sizeof(*eks) * nkeys); 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 */ zend_hash_internal_pointer_reset_ex(pubkeysht, &pos); diff --git a/ext/openssl/tests/002.phpt b/ext/openssl/tests/002.phpt new file mode 100644 index 0000000000..d1b393ec06 --- /dev/null +++ b/ext/openssl/tests/002.phpt @@ -0,0 +1,32 @@ +--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 |