From 2229e563e45ad73b0c8aa7f78ae732705970a10c Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Wed, 30 Aug 2006 20:49:46 +0000 Subject: [PATCH] fix segfault in openssl_seal(), add test --- ext/openssl/openssl.c | 2 ++ ext/openssl/tests/002.phpt | 45 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 ext/openssl/tests/002.phpt diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 6d7cf7bf68..be4534b5e5 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -3041,7 +3041,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..42b1fdb0d3 --- /dev/null +++ b/ext/openssl/tests/002.phpt @@ -0,0 +1,45 @@ +--TEST-- +openssl_seal() tests +--SKIPIF-- + +--FILE-- + +--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 -- 2.40.0