summaryrefslogtreecommitdiff
path: root/ext/mcrypt
diff options
context:
space:
mode:
authorkrakjoe <joe.watkins@live.co.uk>2014-05-06 09:08:02 +0100
committerkrakjoe <joe.watkins@live.co.uk>2014-05-06 09:08:02 +0100
commit4187be99fe1cfd6c66f30f2c23bf1ba2c2f425e1 (patch)
tree444787a31d0def3e3ce8e05f64eaec07cc3c2327 /ext/mcrypt
parent362e1db428c08f4ff8cac3b059b36013c398fada (diff)
downloadphp-git-4187be99fe1cfd6c66f30f2c23bf1ba2c2f425e1.tar.gz
fix for phpng, failing RFC2144 test
Diffstat (limited to 'ext/mcrypt')
-rw-r--r--ext/mcrypt/mcrypt.c54
-rw-r--r--ext/mcrypt/mcrypt_filter.c48
2 files changed, 51 insertions, 51 deletions
diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c
index 1418235bc3..28d8faa351 100644
--- a/ext/mcrypt/mcrypt.c
+++ b/ext/mcrypt/mcrypt.c
@@ -330,7 +330,7 @@ typedef enum {
*/
#define MCRYPT_GET_CRYPT_ARGS \
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sssZ|s", \
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sssz|s", \
&cipher, &cipher_len, &key, &key_len, &data, &data_len, &mode, &iv, &iv_len) == FAILURE) { \
return; \
}
@@ -341,7 +341,7 @@ typedef enum {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &mcryptind) == FAILURE) { \
return; \
} \
- ZEND_FETCH_RESOURCE (pm, php_mcrypt *, &mcryptind, -1, "MCrypt", le_mcrypt);
+ ZEND_FETCH_RESOURCE (pm, php_mcrypt *, mcryptind, -1, "MCrypt", le_mcrypt);
#define MCRYPT_GET_MODE_DIR_ARGS(DIRECTORY) \
char *dir = NULL; \
@@ -369,7 +369,7 @@ PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("mcrypt.modes_dir", NULL, PHP_INI_ALL, OnUpdateString, modes_dir, zend_mcrypt_globals, mcrypt_globals)
PHP_INI_END()
-static void php_mcrypt_module_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */
+static void php_mcrypt_module_dtor(zend_resource *rsrc TSRMLS_DC) /* {{{ */
{
php_mcrypt *pm = (php_mcrypt *) rsrc->ptr;
if (pm) {
@@ -491,8 +491,8 @@ PHP_MINFO_FUNCTION(mcrypt) /* {{{ */
php_info_print_table_header(2, "mcrypt_filter support", "enabled");
php_info_print_table_row(2, "Version", LIBMCRYPT_VERSION);
php_info_print_table_row(2, "Api No", mcrypt_api_no);
- php_info_print_table_row(2, "Supported ciphers", tmp1.c);
- php_info_print_table_row(2, "Supported modes", tmp2.c);
+ php_info_print_table_row(2, "Supported ciphers", tmp1.s->val);
+ php_info_print_table_row(2, "Supported modes", tmp2.s->val);
smart_str_free(&tmp1);
smart_str_free(&tmp2);
php_info_print_table_end();
@@ -553,7 +553,7 @@ PHP_FUNCTION(mcrypt_generic_init)
return;
}
- ZEND_FETCH_RESOURCE(pm, php_mcrypt *, &mcryptind, -1, "MCrypt", le_mcrypt);
+ ZEND_FETCH_RESOURCE(pm, php_mcrypt *, mcryptind, -1, "MCrypt", le_mcrypt);
max_key_size = mcrypt_enc_get_key_size(pm->td);
iv_size = mcrypt_enc_get_iv_size(pm->td);
@@ -587,7 +587,7 @@ PHP_FUNCTION(mcrypt_generic_init)
/* If this function fails, close the mcrypt module to prevent crashes
* when further functions want to access this resource */
if (result < 0) {
- zend_list_delete(Z_LVAL_P(mcryptind));
+ zend_list_delete(Z_RES_P(mcryptind));
switch (result) {
case -3:
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Key length incorrect");
@@ -624,7 +624,7 @@ PHP_FUNCTION(mcrypt_generic)
return;
}
- ZEND_FETCH_RESOURCE(pm, php_mcrypt *, &mcryptind, -1, "MCrypt", le_mcrypt);
+ ZEND_FETCH_RESOURCE(pm, php_mcrypt *, mcryptind, -1, "MCrypt", le_mcrypt);
PHP_MCRYPT_INIT_CHECK
if (data_len == 0) {
@@ -649,7 +649,7 @@ PHP_FUNCTION(mcrypt_generic)
mcrypt_generic(pm->td, data_s, data_size);
data_s[data_size] = '\0';
- RETVAL_STRINGL(data_s, data_size, 1);
+ RETVAL_STRINGL(data_s, data_size);
efree(data_s);
}
/* }}} */
@@ -669,7 +669,7 @@ PHP_FUNCTION(mdecrypt_generic)
return;
}
- ZEND_FETCH_RESOURCE(pm, php_mcrypt * , &mcryptind, -1, "MCrypt", le_mcrypt);
+ ZEND_FETCH_RESOURCE(pm, php_mcrypt * , mcryptind, -1, "MCrypt", le_mcrypt);
PHP_MCRYPT_INIT_CHECK
if (data_len == 0) {
@@ -693,7 +693,7 @@ PHP_FUNCTION(mdecrypt_generic)
mdecrypt_generic(pm->td, data_s, data_size);
- RETVAL_STRINGL(data_s, data_size, 1);
+ RETVAL_STRINGL(data_s, data_size);
efree(data_s);
}
/* }}} */
@@ -732,7 +732,7 @@ PHP_FUNCTION(mcrypt_enc_self_test)
PHP_FUNCTION(mcrypt_module_close)
{
MCRYPT_GET_TD_ARG
- zend_list_delete(Z_LVAL_P(mcryptind));
+ zend_list_delete(Z_RES_P(mcryptind));
RETURN_TRUE;
}
/* }}} */
@@ -829,7 +829,7 @@ PHP_FUNCTION(mcrypt_enc_get_algorithms_name)
MCRYPT_GET_TD_ARG
name = mcrypt_enc_get_algorithms_name(pm->td);
- RETVAL_STRING(name, 1);
+ RETVAL_STRING(name);
mcrypt_free(name);
}
/* }}} */
@@ -842,7 +842,7 @@ PHP_FUNCTION(mcrypt_enc_get_modes_name)
MCRYPT_GET_TD_ARG
name = mcrypt_enc_get_modes_name(pm->td);
- RETVAL_STRING(name, 1);
+ RETVAL_STRING(name);
mcrypt_free(name);
}
/* }}} */
@@ -1107,14 +1107,14 @@ PHP_FUNCTION(mcrypt_get_cipher_name)
if (td != MCRYPT_FAILED) {
cipher_name = mcrypt_enc_get_algorithms_name(td);
mcrypt_module_close(td);
- RETVAL_STRING(cipher_name,1);
+ RETVAL_STRING(cipher_name);
mcrypt_free(cipher_name);
} else {
td = mcrypt_module_open(cipher, cipher_dir_string, "stream", module_dir_string);
if (td != MCRYPT_FAILED) {
cipher_name = mcrypt_enc_get_algorithms_name(td);
mcrypt_module_close(td);
- RETVAL_STRING(cipher_name,1);
+ RETVAL_STRING(cipher_name);
mcrypt_free(cipher_name);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, MCRYPT_OPEN_MODULE_FAILED);
@@ -1152,7 +1152,7 @@ static char *php_mcrypt_get_key_size_str(
smart_str_appends(&str, " supported");
smart_str_0(&str);
- return str.c;
+ return str.s->val;
}
}
/* }}} */
@@ -1285,7 +1285,7 @@ static void php_mcrypt_do_crypt(char* cipher, const char *key, int key_len, cons
}
data_s[data_size] = 0;
- RETVAL_STRINGL(data_s, data_size, 0);
+ RETVAL_STRINGL(data_s, data_size);
/* freeing vars */
mcrypt_generic_end(td);
@@ -1328,7 +1328,7 @@ PHP_FUNCTION(mcrypt_decrypt)
ECB crypt/decrypt data using key key with cipher cipher starting with iv */
PHP_FUNCTION(mcrypt_ecb)
{
- zval **mode;
+ zval *mode;
char *cipher, *key, *data, *iv = NULL;
int cipher_len, key_len, data_len, iv_len = 0;
@@ -1336,7 +1336,7 @@ PHP_FUNCTION(mcrypt_ecb)
convert_to_long_ex(mode);
- php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, "ecb", iv, iv_len, Z_LVAL_PP(mode), return_value TSRMLS_CC);
+ php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, "ecb", iv, iv_len, Z_LVAL_P(mode), return_value TSRMLS_CC);
}
/* }}} */
@@ -1344,7 +1344,7 @@ PHP_FUNCTION(mcrypt_ecb)
CBC crypt/decrypt data using key key with cipher cipher starting with iv */
PHP_FUNCTION(mcrypt_cbc)
{
- zval **mode;
+ zval *mode;
char *cipher, *key, *data, *iv = NULL;
int cipher_len, key_len, data_len, iv_len = 0;
@@ -1352,7 +1352,7 @@ PHP_FUNCTION(mcrypt_cbc)
convert_to_long_ex(mode);
- php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, "cbc", iv, iv_len, Z_LVAL_PP(mode), return_value TSRMLS_CC);
+ php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, "cbc", iv, iv_len, Z_LVAL_P(mode), return_value TSRMLS_CC);
}
/* }}} */
@@ -1360,7 +1360,7 @@ PHP_FUNCTION(mcrypt_cbc)
CFB crypt/decrypt data using key key with cipher cipher starting with iv */
PHP_FUNCTION(mcrypt_cfb)
{
- zval **mode;
+ zval *mode;
char *cipher, *key, *data, *iv = NULL;
int cipher_len, key_len, data_len, iv_len = 0;
@@ -1368,7 +1368,7 @@ PHP_FUNCTION(mcrypt_cfb)
convert_to_long_ex(mode);
- php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, "cfb", iv, iv_len, Z_LVAL_PP(mode), return_value TSRMLS_CC);
+ php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, "cfb", iv, iv_len, Z_LVAL_P(mode), return_value TSRMLS_CC);
}
/* }}} */
@@ -1376,7 +1376,7 @@ PHP_FUNCTION(mcrypt_cfb)
OFB crypt/decrypt data using key key with cipher cipher starting with iv */
PHP_FUNCTION(mcrypt_ofb)
{
- zval **mode;
+ zval *mode;
char *cipher, *key, *data, *iv = NULL;
int cipher_len, key_len, data_len, iv_len = 0;
@@ -1384,7 +1384,7 @@ PHP_FUNCTION(mcrypt_ofb)
convert_to_long_ex(mode);
- php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, "ofb", iv, iv_len, Z_LVAL_PP(mode), return_value TSRMLS_CC);
+ php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, "ofb", iv, iv_len, Z_LVAL_P(mode), return_value TSRMLS_CC);
}
/* }}} */
@@ -1449,7 +1449,7 @@ PHP_FUNCTION(mcrypt_create_iv)
iv[--size] = (char) (255.0 * php_rand(TSRMLS_C) / RAND_MAX);
}
}
- RETURN_STRINGL(iv, n, 0);
+ RETURN_STRINGL(iv, n);
}
/* }}} */
diff --git a/ext/mcrypt/mcrypt_filter.c b/ext/mcrypt/mcrypt_filter.c
index cc32be649a..698664b236 100644
--- a/ext/mcrypt/mcrypt_filter.c
+++ b/ext/mcrypt/mcrypt_filter.c
@@ -46,12 +46,12 @@ static php_stream_filter_status_t php_mcrypt_filter(
size_t consumed = 0;
php_stream_filter_status_t exit_status = PSFS_FEED_ME;
- if (!thisfilter || !thisfilter->abstract) {
+ if (!thisfilter || !Z_PTR(thisfilter->abstract)) {
/* Should never happen */
return PSFS_ERR_FATAL;
}
- data = (php_mcrypt_filter_data *)(thisfilter->abstract);
+ data = (php_mcrypt_filter_data *)(Z_PTR(thisfilter->abstract));
while(buckets_in->head) {
bucket = buckets_in->head;
@@ -126,8 +126,8 @@ static php_stream_filter_status_t php_mcrypt_filter(
static void php_mcrypt_filter_dtor(php_stream_filter *thisfilter TSRMLS_DC)
{
- if (thisfilter && thisfilter->abstract) {
- php_mcrypt_filter_data *data = (php_mcrypt_filter_data*)thisfilter->abstract;
+ if (thisfilter && Z_PTR(thisfilter->abstract)) {
+ php_mcrypt_filter_data *data = (php_mcrypt_filter_data*) Z_PTR(thisfilter->abstract);
if (data->block_buffer) {
pefree(data->block_buffer, data->persistent);
@@ -153,7 +153,7 @@ static php_stream_filter *php_mcrypt_filter_create(const char *filtername, zval
{
int encrypt = 1, iv_len, key_len, keyl, result;
const char *cipher = filtername + sizeof("mcrypt.") - 1;
- zval **tmpzval;
+ zval *tmpzval;
MCRYPT mcrypt_module;
char *iv = NULL, *key = NULL;
char *algo_dir = INI_STR("mcrypt.algorithms_dir");
@@ -174,34 +174,34 @@ static php_stream_filter *php_mcrypt_filter_create(const char *filtername, zval
return NULL;
}
- if (zend_hash_find(HASH_OF(filterparams), "mode", sizeof("mode"), (void**)&tmpzval) == SUCCESS) {
- if (Z_TYPE_PP(tmpzval) == IS_STRING) {
- mode = Z_STRVAL_PP(tmpzval);
+ if ((tmpzval = zend_hash_str_find(HASH_OF(filterparams), ZEND_STRL("mode")))) {
+ if (Z_TYPE_P(tmpzval) == IS_STRING) {
+ mode = Z_STRVAL_P(tmpzval);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "mode is not a string, ignoring");
}
}
- if (zend_hash_find(HASH_OF(filterparams), "algorithms_dir", sizeof("algorithms_dir"), (void**)&tmpzval) == SUCCESS) {
- if (Z_TYPE_PP(tmpzval) == IS_STRING) {
- algo_dir = Z_STRVAL_PP(tmpzval);
+ if ((tmpzval=zend_hash_str_find(HASH_OF(filterparams), ZEND_STRL("algorithms_dir")))) {
+ if (Z_TYPE_P(tmpzval) == IS_STRING) {
+ algo_dir = Z_STRVAL_P(tmpzval);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "algorithms_dir is not a string, ignoring");
}
}
- if (zend_hash_find(HASH_OF(filterparams), "modes_dir", sizeof("modes_dir"), (void**)&tmpzval) == SUCCESS) {
- if (Z_TYPE_PP(tmpzval) == IS_STRING) {
- mode_dir = Z_STRVAL_PP(tmpzval);
+ if ((tmpzval=zend_hash_str_find(HASH_OF(filterparams), ZEND_STRL("modes_dir")))) {
+ if (Z_TYPE_P(tmpzval) == IS_STRING) {
+ mode_dir = Z_STRVAL_P(tmpzval);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "modes_dir is not a string, ignoring");
}
}
- if (zend_hash_find(HASH_OF(filterparams), "key", sizeof("key"), (void**)&tmpzval) == SUCCESS &&
- Z_TYPE_PP(tmpzval) == IS_STRING) {
- key = Z_STRVAL_PP(tmpzval);
- key_len = Z_STRLEN_PP(tmpzval);
+ if ((tmpzval = zend_hash_str_find(HASH_OF(filterparams), ZEND_STRL("key"))) &&
+ Z_TYPE_P(tmpzval) == IS_STRING) {
+ key = Z_STRVAL_P(tmpzval);
+ key_len = Z_STRLEN_P(tmpzval);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "key not specified or is not a string");
return NULL;
@@ -218,19 +218,19 @@ static php_stream_filter *php_mcrypt_filter_create(const char *filtername, zval
key_len = keyl;
}
- if (zend_hash_find(HASH_OF(filterparams), "iv", sizeof("iv"), (void**) &tmpzval) == FAILURE ||
- Z_TYPE_PP(tmpzval) != IS_STRING) {
+ if (!(tmpzval = zend_hash_str_find(HASH_OF(filterparams), ZEND_STRL("iv"))) ||
+ Z_TYPE_P(tmpzval) != IS_STRING) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filter parameter[iv] not provided or not of type: string");
mcrypt_module_close(mcrypt_module);
return NULL;
}
iv = emalloc(iv_len + 1);
- if (iv_len <= Z_STRLEN_PP(tmpzval)) {
- memcpy(iv, Z_STRVAL_PP(tmpzval), iv_len);
+ if (iv_len <= Z_STRLEN_P(tmpzval)) {
+ memcpy(iv, Z_STRVAL_P(tmpzval), iv_len);
} else {
- memcpy(iv, Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval));
- memset(iv + Z_STRLEN_PP(tmpzval), 0, iv_len - Z_STRLEN_PP(tmpzval));
+ memcpy(iv, Z_STRVAL_P(tmpzval), Z_STRLEN_P(tmpzval));
+ memset(iv + Z_STRLEN_P(tmpzval), 0, iv_len - Z_STRLEN_P(tmpzval));
}
result = mcrypt_generic_init(mcrypt_module, key, key_len, iv);