From bd59a23e0a34734caf47086134f64253d1a04d5f Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Mon, 16 Dec 2002 09:03:11 +0000 Subject: [PATCH] - Fix bug #21039 #- This is somewhat of a hack, and thus I will not merge it to HEAD, as # I've lots of other commits waiting for that. --- ext/mcrypt/mcrypt.c | 13 ++++++++++--- ext/mcrypt/tests/bug21039.phpt | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 ext/mcrypt/tests/bug21039.phpt diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c index c242d08305..6b66353cf1 100644 --- a/ext/mcrypt/mcrypt.c +++ b/ext/mcrypt/mcrypt.c @@ -182,6 +182,13 @@ ZEND_GET_MODULE(mcrypt) WRONG_PARAM_COUNT; \ } +#define MCRYPT_CHECK_PARAM_COUNT_EX(a,b) \ + if (argc < (a) || argc > (b)) { \ + zend_get_parameters_ex(1, &mcryptind); \ + zend_list_delete (Z_LVAL_PP(mcryptind)); \ + WRONG_PARAM_COUNT; \ + } + #define MCRYPT_GET_CRYPT_ARGS \ switch (argc) { \ case 5: \ @@ -455,7 +462,7 @@ PHP_FUNCTION(mcrypt_generic_init) int result = 0; argc = ZEND_NUM_ARGS(); - MCRYPT_CHECK_PARAM_COUNT (3,3) + MCRYPT_CHECK_PARAM_COUNT_EX (3,3) zend_get_parameters_ex(3, &mcryptind, &key, &iv); ZEND_FETCH_RESOURCE (td, MCRYPT, mcryptind, -1, "MCrypt", le_mcrypt); @@ -530,7 +537,7 @@ PHP_FUNCTION(mcrypt_generic) int block_size, data_size; argc = ZEND_NUM_ARGS(); - MCRYPT_CHECK_PARAM_COUNT (2,2) + MCRYPT_CHECK_PARAM_COUNT_EX (2,2) zend_get_parameters_ex(2, &mcryptind, &data); ZEND_FETCH_RESOURCE (td, MCRYPT, mcryptind, -1, "MCrypt", le_mcrypt); @@ -571,7 +578,7 @@ PHP_FUNCTION(mdecrypt_generic) int block_size, data_size; argc = ZEND_NUM_ARGS(); - MCRYPT_CHECK_PARAM_COUNT (2,2) + MCRYPT_CHECK_PARAM_COUNT_EX (2,2) zend_get_parameters_ex(2, &mcryptind, &data); ZEND_FETCH_RESOURCE (td, MCRYPT, mcryptind, -1, "MCrypt", le_mcrypt); diff --git a/ext/mcrypt/tests/bug21039.phpt b/ext/mcrypt/tests/bug21039.phpt new file mode 100644 index 0000000000..c290c82195 --- /dev/null +++ b/ext/mcrypt/tests/bug21039.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #21039 +--SKIPIF-- + +--POST-- +--GET-- +--FILE-- + +--EXPECT-- +I'm alive! -- 2.50.1