From cd314aea490523c84df26d3143fd21527c8c8021 Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Sat, 29 Jul 2006 22:24:49 +0000 Subject: [PATCH] - MFH: #38255, fix possible leak in php_openssl_evp_from_zval --- ext/openssl/openssl.c | 3 +++ ext/openssl/tests/bug38255.phpt | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 ext/openssl/tests/bug38255.phpt diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 5cb9a403f8..7fa5c40331 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -1824,6 +1824,9 @@ static EVP_PKEY * php_openssl_evp_from_zval(zval ** val, int public_key, char * return NULL; } else { /* force it to be a string and check if it refers to a file */ + if (Z_TYPE_PP(val) == IS_LONG || Z_TYPE_PP(val) == IS_BOOL) { + return NULL; + } convert_to_string_ex(val); if (Z_STRLEN_PP(val) > 7 && memcmp(Z_STRVAL_PP(val), "file://", sizeof("file://") - 1) == 0) { diff --git a/ext/openssl/tests/bug38255.phpt b/ext/openssl/tests/bug38255.phpt new file mode 100644 index 0000000000..45b2817fde --- /dev/null +++ b/ext/openssl/tests/bug38255.phpt @@ -0,0 +1,14 @@ +--TEST-- +openssl key from zval leaks +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: openssl_verify(): supplied key param cannot be coerced into a public key in %s/bug38255.php on line %d -- 2.50.1