@@ -1030,7 +1030,7 @@ int php_mcrypt_func(php_mcrypt_op op, char *cipher, char *mode, char *key_str, i
1030
1030
{
1031
1031
MCRYPT td ;
1032
1032
char * cipher_dir_string , * module_dir_string , * key_copy , * iv_copy ;
1033
- int i , status = SUCCESS , count , * key_sizes , key_size , iv_size , block_size ;
1033
+ int i , status = SUCCESS , count , * key_sizes , key_size , iv_size , block_size , iv_req ;
1034
1034
1035
1035
MCRYPT_GET_INI
1036
1036
@@ -1068,6 +1068,7 @@ int php_mcrypt_func(php_mcrypt_op op, char *cipher, char *mode, char *key_str, i
1068
1068
mcrypt_free (key_sizes );
1069
1069
1070
1070
iv_size = mcrypt_enc_get_iv_size (td );
1071
+ iv_req = mcrypt_enc_mode_has_iv (td );
1071
1072
if (iv_len ) {
1072
1073
if (iv_len == iv_size ) {
1073
1074
iv_copy = estrndup (iv_str , iv_len );
@@ -1077,7 +1078,9 @@ int php_mcrypt_func(php_mcrypt_op op, char *cipher, char *mode, char *key_str, i
1077
1078
memcpy (iv_copy , iv_str , MIN (iv_len , iv_size ));
1078
1079
}
1079
1080
} else {
1080
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "Attempt to use an empty IV, which is NOT recommended" );
1081
+ if (iv_req ) {
1082
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "Attempt to use an empty IV, which is NOT recommended" );
1083
+ }
1081
1084
iv_copy = ecalloc (1 , iv_size );
1082
1085
}
1083
1086
0 commit comments