summaryrefslogtreecommitdiff
path: root/ext/mcrypt/mcrypt.c
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2014-03-05 15:18:27 +0100
committerNikita Popov <nikic@php.net>2014-03-05 15:32:32 +0100
commitd8ed84e4c4d0bd0bac88d2c0ed6e072a7d7ea49d (patch)
tree22d064dd8a0c9f761d511e7e61d66ca151c85c2d /ext/mcrypt/mcrypt.c
parenteb0eac75efaf76eb7772c6cd7768a581aeb6de8f (diff)
downloadphp-git-d8ed84e4c4d0bd0bac88d2c0ed6e072a7d7ea49d.tar.gz
Use zpp for accepting encryption mode string
Leaving the non-zpp usage for the mcrypt_{MODE} functions, as they're deprecated and I'm too lazy to update all their tests.
Diffstat (limited to 'ext/mcrypt/mcrypt.c')
-rw-r--r--ext/mcrypt/mcrypt.c28
1 files changed, 14 insertions, 14 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);
}
/* }}} */