com php-src: Call mcrypt_module_close on error: ext /mcrypt/mcrypt.c
| From: | Nikita Popov | Date: | Wed, 05 Mar 2014 14:32:32 +0000 |
| Subject: | com php-src: Call mcrypt_module_close on error: ext /mcrypt/mcrypt.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-76351@lists.php.net to get a copy of this message | ||
Commit: b9737aa08ea2228e23b3f9289189a14a7cfda800
Author: Nikita Popov <nikic@php.net> Sun, 2 Mar 2014 23:26:46 +0100
Parents: e4876ecbfb36a0a3de8f0a10ab20d607932cf59e
Branches: PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b9737aa08ea2228e23b3f9289189a14a7cfda800
Log:
Call mcrypt_module_close on error
Changed paths:
M ext/mcrypt/mcrypt.c
Diff:
diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c
index a9f34d7..a8dbc42 100644
--- a/ext/mcrypt/mcrypt.c
+++ b/ext/mcrypt/mcrypt.c
@@ -1268,6 +1268,7 @@ static void php_mcrypt_do_crypt(char* cipher, const char *key, int key_len,
cons
/* Checking for key-length */
if (php_mcrypt_ensure_valid_key_size(td, key_len TSRMLS_CC) == FAILURE) {
+ mcrypt_module_close(td);
RETURN_FALSE;
}
@@ -1275,11 +1276,13 @@ static void php_mcrypt_do_crypt(char* cipher, const char *key, int key_len,
cons
if (mcrypt_enc_mode_has_iv(td) == 1) {
if (!iv) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Encryption mode requires an initialization
vector");
+ mcrypt_module_close(td);
RETURN_FALSE;
}
if (iv_len != mcrypt_enc_get_iv_size(td)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, MCRYPT_IV_WRONG_SIZE);
+ mcrypt_module_close(td);
RETURN_FALSE;
}
}
@@ -1299,6 +1302,7 @@ static void php_mcrypt_do_crypt(char* cipher, const char *key, int key_len,
cons
if (mcrypt_generic_init(td, (void *) key, key_len, (void *) iv) < 0) {
php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Mcrypt initialisation failed");
+ mcrypt_module_close(td);
RETURN_FALSE;
}