summaryrefslogtreecommitdiff
path: root/ext/mcrypt/mcrypt.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mcrypt/mcrypt.c')
-rw-r--r--ext/mcrypt/mcrypt.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c
index 600e9ae379..4f1954a641 100644
--- a/ext/mcrypt/mcrypt.c
+++ b/ext/mcrypt/mcrypt.c
@@ -456,6 +456,11 @@ PHP_FUNCTION(mcrypt_generic_init)
max_key_size = mcrypt_enc_get_key_size (td);
iv_size = mcrypt_enc_get_iv_size (td);
+ if (Z_STRLEN_PP(key) == 0) {
+ php_error (E_WARNING, "key size is 0");
+ RETURN_FALSE;
+ }
+
key_s = emalloc (Z_STRLEN_PP(key));
memset (key_s, 0, Z_STRLEN_PP(key));