summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/mcrypt/mcrypt.c28
-rw-r--r--ext/mcrypt/tests/mcrypt_decrypt_variation4.phpt30
-rw-r--r--ext/mcrypt/tests/mcrypt_encrypt_variation4.phpt30
3 files changed, 38 insertions, 50 deletions
diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c
index ada3fb7143..70a458d976 100644
--- a/ext/mcrypt/mcrypt.c
+++ b/ext/mcrypt/mcrypt.c
@@ -1296,15 +1296,15 @@ static void php_mcrypt_do_crypt(char* cipher, const char *key, int key_len, cons
OFB crypt/decrypt data using key key with cipher cipher starting with iv */
PHP_FUNCTION(mcrypt_encrypt)
{
- zval **mode;
- char *cipher, *key, *data, *iv = NULL;
- int cipher_len, key_len, data_len, iv_len = 0;
+ char *cipher, *key, *data, *mode, *iv = NULL;
+ int cipher_len, key_len, data_len, mode_len, iv_len = 0;
- MCRYPT_GET_CRYPT_ARGS
-
- convert_to_string_ex(mode);
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssss|s", &cipher, &cipher_len,
+ &key, &key_len, &data, &data_len, &mode, &mode_len, &iv, &iv_len) == FAILURE) {
+ return;
+ }
- php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, Z_STRVAL_PP(mode), iv, iv_len, MCRYPT_ENCRYPT, return_value TSRMLS_CC);
+ php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, mode, iv, iv_len, MCRYPT_ENCRYPT, return_value TSRMLS_CC);
}
/* }}} */
@@ -1312,15 +1312,15 @@ PHP_FUNCTION(mcrypt_encrypt)
OFB crypt/decrypt data using key key with cipher cipher starting with iv */
PHP_FUNCTION(mcrypt_decrypt)
{
- zval **mode;
- char *cipher, *key, *data, *iv = NULL;
- int cipher_len, key_len, data_len, iv_len = 0;
+ char *cipher, *key, *data, *mode, *iv = NULL;
+ int cipher_len, key_len, data_len, mode_len, iv_len = 0;
- MCRYPT_GET_CRYPT_ARGS
-
- convert_to_string_ex(mode);
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssss|s", &cipher, &cipher_len,
+ &key, &key_len, &data, &data_len, &mode, &mode_len, &iv, &iv_len) == FAILURE) {
+ return;
+ }
- php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, Z_STRVAL_PP(mode), iv, iv_len, MCRYPT_DECRYPT, return_value TSRMLS_CC);
+ php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, mode, iv, iv_len, MCRYPT_DECRYPT, return_value TSRMLS_CC);
}
/* }}} */
diff --git a/ext/mcrypt/tests/mcrypt_decrypt_variation4.phpt b/ext/mcrypt/tests/mcrypt_decrypt_variation4.phpt
index 12e44312d8..1bb994dcc7 100644
--- a/ext/mcrypt/tests/mcrypt_decrypt_variation4.phpt
+++ b/ext/mcrypt/tests/mcrypt_decrypt_variation4.phpt
@@ -160,24 +160,20 @@ Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
bool(false)
--empty array--
-Error: 8 - Array to string conversion, %s(%d)
-Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
-bool(false)
+Error: 2 - mcrypt_decrypt() expects parameter 4 to be string, array given, %s(%d)
+NULL
--int indexed array--
-Error: 8 - Array to string conversion, %s(%d)
-Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
-bool(false)
+Error: 2 - mcrypt_decrypt() expects parameter 4 to be string, array given, %s(%d)
+NULL
--associative array--
-Error: 8 - Array to string conversion, %s(%d)
-Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
-bool(false)
+Error: 2 - mcrypt_decrypt() expects parameter 4 to be string, array given, %s(%d)
+NULL
--nested arrays--
-Error: 8 - Array to string conversion, %s(%d)
-Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
-bool(false)
+Error: 2 - mcrypt_decrypt() expects parameter 4 to be string, array given, %s(%d)
+NULL
--uppercase NULL--
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
@@ -216,10 +212,8 @@ Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
bool(false)
--instance of classWithoutToString--
-Error: 4096 - Object of class classWithoutToString could not be converted to string, %s(%d)
-Error: 8 - Object of class classWithoutToString to string conversion, %s(%d)
-Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
-bool(false)
+Error: 2 - mcrypt_decrypt() expects parameter 4 to be string, object given, %s(%d)
+NULL
--undefined var--
Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
@@ -230,6 +224,6 @@ Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
bool(false)
--resource--
-Error: 2 - mcrypt_decrypt(): Module initialization failed, %s(%d)
-bool(false)
+Error: 2 - mcrypt_decrypt() expects parameter 4 to be string, resource given, %s(%d)
+NULL
===DONE===
diff --git a/ext/mcrypt/tests/mcrypt_encrypt_variation4.phpt b/ext/mcrypt/tests/mcrypt_encrypt_variation4.phpt
index 4c8cef1db3..a041ab437e 100644
--- a/ext/mcrypt/tests/mcrypt_encrypt_variation4.phpt
+++ b/ext/mcrypt/tests/mcrypt_encrypt_variation4.phpt
@@ -160,24 +160,20 @@ Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
bool(false)
--empty array--
-Error: 8 - Array to string conversion, %s(%d)
-Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
-bool(false)
+Error: 2 - mcrypt_encrypt() expects parameter 4 to be string, array given, %s(%d)
+NULL
--int indexed array--
-Error: 8 - Array to string conversion, %s(%d)
-Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
-bool(false)
+Error: 2 - mcrypt_encrypt() expects parameter 4 to be string, array given, %s(%d)
+NULL
--associative array--
-Error: 8 - Array to string conversion, %s(%d)
-Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
-bool(false)
+Error: 2 - mcrypt_encrypt() expects parameter 4 to be string, array given, %s(%d)
+NULL
--nested arrays--
-Error: 8 - Array to string conversion, %s(%d)
-Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
-bool(false)
+Error: 2 - mcrypt_encrypt() expects parameter 4 to be string, array given, %s(%d)
+NULL
--uppercase NULL--
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
@@ -216,10 +212,8 @@ Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
bool(false)
--instance of classWithoutToString--
-Error: 4096 - Object of class classWithoutToString could not be converted to string, %s(%d)
-Error: 8 - Object of class classWithoutToString to string conversion, %s(%d)
-Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
-bool(false)
+Error: 2 - mcrypt_encrypt() expects parameter 4 to be string, object given, %s(%d)
+NULL
--undefined var--
Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
@@ -230,6 +224,6 @@ Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
bool(false)
--resource--
-Error: 2 - mcrypt_encrypt(): Module initialization failed, %s(%d)
-bool(false)
+Error: 2 - mcrypt_encrypt() expects parameter 4 to be string, resource given, %s(%d)
+NULL
===DONE===