summaryrefslogtreecommitdiff
path: root/ext/mcrypt
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2014-12-08 12:20:01 +0300
committerDmitry Stogov <dmitry@zend.com>2014-12-08 12:20:01 +0300
commite6ad29ae96caec9353e42d528895bf2bec02a125 (patch)
treebfa06b2e81d604b86bf1a26a780af93da682abbc /ext/mcrypt
parent5d126245a3bb71b167a3b02a9d874c9247b556ff (diff)
parentdd791cd71742fdb9b87b7166537fbb25bd7cd8b9 (diff)
downloadphp-git-e6ad29ae96caec9353e42d528895bf2bec02a125.tar.gz
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4: Fixed possible read after end of buffer and use after free.
Diffstat (limited to 'ext/mcrypt')
-rw-r--r--ext/mcrypt/mcrypt.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c
index 89ad83f6bf..9a94e3b8d2 100644
--- a/ext/mcrypt/mcrypt.c
+++ b/ext/mcrypt/mcrypt.c
@@ -619,8 +619,11 @@ PHP_FUNCTION(mcrypt_generic_init)
if (iv_len != iv_size) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Iv size incorrect; supplied length: %d, needed: %d", iv_len, iv_size);
+ if (iv_len > iv_size) {
+ iv_len = iv_size;
+ }
}
- memcpy(iv_s, iv, iv_size);
+ memcpy(iv_s, iv, iv_len);
mcrypt_generic_deinit(pm->td);
result = mcrypt_generic_init(pm->td, key_s, key_size, iv_s);
@@ -641,8 +644,9 @@ PHP_FUNCTION(mcrypt_generic_init)
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown error");
break;
}
+ } else {
+ pm->init = 1;
}
- pm->init = 1;
RETVAL_LONG(result);
efree(iv_s);