diff options
author | Henrique do Nascimento Angelo <hnangelo@php.net> | 2008-06-28 09:24:18 +0000 |
---|---|---|
committer | Henrique do Nascimento Angelo <hnangelo@php.net> | 2008-06-28 09:24:18 +0000 |
commit | d44509418efa19d8c6ecf10def3e3eaf835e34b3 (patch) | |
tree | 0617d3892f42eeaf65e1d62e5109a6d493a6581e /ext/openssl/openssl.c | |
parent | 9c812109d46e535faae3a6223149c54e2769e997 (diff) | |
download | php-git-d44509418efa19d8c6ecf10def3e3eaf835e34b3.tar.gz |
Fix a memory leak on openssl_decrypt()
Diffstat (limited to 'ext/openssl/openssl.c')
-rw-r--r-- | ext/openssl/openssl.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 920a5fc3c6..4f653921c1 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -4691,10 +4691,9 @@ PHP_FUNCTION(openssl_decrypt) return; } - if (!raw_input) { - base64_str = (char*)php_base64_decode((unsigned char*)data, data_len, &base64_str_len); - data_len = base64_str_len; - data = base64_str; + if (!method_len) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown cipher algorithm"); + RETURN_FALSE; } cipher_type = EVP_get_cipherbyname(method); @@ -4703,6 +4702,12 @@ PHP_FUNCTION(openssl_decrypt) RETURN_FALSE; } + if (!raw_input) { + base64_str = (char*)php_base64_decode((unsigned char*)data, data_len, &base64_str_len); + data_len = base64_str_len; + data = base64_str; + } + keylen = EVP_CIPHER_key_length(cipher_type); if (keylen > password_len) { key = emalloc(keylen); |