com php-src: Store errors in openssl_encrypt and openssl _decrypt: ext/openssl/openssl.c
| From: | Jakub Zelenka | Date: | Sun, 07 Feb 2016 16:40:21 +0000 |
| Subject: | com php-src: Store errors in openssl_encrypt and openssl _decrypt: ext/openssl/openssl.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-92444@lists.php.net to get a copy of this message | ||
Commit: 9b094be5f7099ba1f251fc00399c394ab763b744
Author: Jakub Zelenka <bukka@php.net> Sun, 7 Feb 2016 16:40:21 +0000
Parents: 34eb6b53ccf5b7048e1808f5c9e48d4c8009a9c1
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9b094be5f7099ba1f251fc00399c394ab763b744
Log:
Store errors in openssl_encrypt and openssl_decrypt
Changed paths:
M ext/openssl/openssl.c
Diff:
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index 84e92d6...21c6e81 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -5584,7 +5584,9 @@ PHP_FUNCTION(openssl_encrypt)
EVP_EncryptInit(&cipher_ctx, cipher_type, NULL, NULL);
if (password_len > keylen) {
PHP_OPENSSL_CHECK_SIZE_T_TO_INT(password_len, password);
- EVP_CIPHER_CTX_set_key_length(&cipher_ctx, (int)password_len);
+ if (!EVP_CIPHER_CTX_set_key_length(&cipher_ctx, (int)password_len)) {
+ php_openssl_store_errors();
+ }
}
EVP_EncryptInit_ex(&cipher_ctx, NULL, NULL, key, (unsigned char *)iv);
if (options & OPENSSL_ZERO_PADDING) {
@@ -5608,6 +5610,7 @@ PHP_FUNCTION(openssl_encrypt)
RETVAL_STR(base64_str);
}
} else {
+ php_openssl_store_errors();
zend_string_release(outbuf);
RETVAL_FALSE;
}
@@ -5680,7 +5683,9 @@ PHP_FUNCTION(openssl_decrypt)
EVP_DecryptInit(&cipher_ctx, cipher_type, NULL, NULL);
if (password_len > keylen) {
PHP_OPENSSL_CHECK_SIZE_T_TO_INT(password_len, password);
- EVP_CIPHER_CTX_set_key_length(&cipher_ctx, (int)password_len);
+ if (!EVP_CIPHER_CTX_set_key_length(&cipher_ctx, (int)password_len)) {
+ php_openssl_store_errors();
+ }
}
EVP_DecryptInit_ex(&cipher_ctx, NULL, NULL, key, (unsigned char *)iv);
if (options & OPENSSL_ZERO_PADDING) {
@@ -5694,6 +5699,7 @@ PHP_FUNCTION(openssl_decrypt)
ZSTR_LEN(outbuf) = outlen;
RETVAL_STR(outbuf);
} else {
+ php_openssl_store_errors();
zend_string_release(outbuf);
RETVAL_FALSE;
}