]> granicus.if.org Git - php/commitdiff
- Fix for bug 14690
authorDerick Rethans <derick@php.net>
Wed, 26 Dec 2001 10:01:50 +0000 (10:01 +0000)
committerDerick Rethans <derick@php.net>
Wed, 26 Dec 2001 10:01:50 +0000 (10:01 +0000)
ext/mcrypt/mcrypt.c

index daf1679922f085166bb07dd3218bb9fbd1a7f28b..bfdc2369b4b26947d48e0b7a86f32f4a6e745a8c 100644 (file)
@@ -207,26 +207,14 @@ ZEND_GET_MODULE(mcrypt)
        ZEND_FETCH_RESOURCE (td, MCRYPT, mcryptind, -1, "MCrypt", le_mcrypt);                           
 
 #define MCRYPT_GET_MODE_DIR_ARGS(DIRECTORY)                                                            \
-       switch (argc) {                                                                                                         \
-               case 2:                                                                                                                 \
-                       lib_dir_s = Z_STRVAL_PP(lib_dir);                                               \
-                       if (zend_get_parameters_ex(2, &arg1, &lib_dir) == FAILURE)      \
-                       {                                                                                                                       \
-                               WRONG_PARAM_COUNT;                                                                              \
-                       }                                                                                                                       \
-                       convert_to_string_ex (lib_dir);                                                         \
-                       break;                                                                                                          \
-               case 1:                                                                                                                 \
-                       lib_dir_s = MCG(DIRECTORY);                                                                     \
-                       if (zend_get_parameters_ex(1, &arg1) == FAILURE)                        \
-                       {                                                                                                                       \
-                               WRONG_PARAM_COUNT;                                                                              \
-                       }                                                                                                                       \
-                       break;                                                                                                          \
-               default:                                                                                                                \
-                       WRONG_PARAM_COUNT;                                                                                      \
-       }                                                                                                                                       \
-       convert_to_string_ex(arg1);
+       char *dir = NULL;                                                   \
+       int   dir_len;                                                      \
+       char *module;                                                       \
+       int   module_len;                                                   \
+       if (zend_parse_parameters (ZEND_NUM_ARGS() TSRMLS_CC,               \
+               "s|s", &module, &module_len, &dir, &dir_len) == FAILURE) {      \
+               return;                                                         \
+       }
        
 #endif
 
@@ -845,15 +833,9 @@ PHP_FUNCTION(mcrypt_enc_get_modes_name)
    Does a self test of the module "module" */
 PHP_FUNCTION(mcrypt_module_self_test)
 {
-       zval **arg1, **lib_dir;
-       char *lib_dir_s;
-       int argc;
-       
-       argc = ZEND_NUM_ARGS();
-
        MCRYPT_GET_MODE_DIR_ARGS(algorithms_dir);
        
-       if (mcrypt_module_self_test (Z_STRVAL_PP(arg1), lib_dir_s) == 0) {
+       if (mcrypt_module_self_test (module, dir) == 0) {
                RETURN_TRUE;
        }
        else {
@@ -867,18 +849,11 @@ PHP_FUNCTION(mcrypt_module_self_test)
    Returns TRUE if the mode is for use with block algorithms */
 PHP_FUNCTION(mcrypt_module_is_block_algorithm_mode)
 {
-       zval **arg1, **lib_dir;
-       char *lib_dir_s;
-       int argc;
-       
-       argc = ZEND_NUM_ARGS();
-
        MCRYPT_GET_MODE_DIR_ARGS(modes_dir)
        
-       if (mcrypt_module_is_block_algorithm_mode (Z_STRVAL_PP(arg1), lib_dir_s) == 0) {
+       if (mcrypt_module_is_block_algorithm_mode (module, dir) == 1) {
                RETURN_TRUE;
-       }
-       else {
+       } else {
                RETURN_FALSE;
        }
 }
@@ -889,18 +864,11 @@ PHP_FUNCTION(mcrypt_module_is_block_algorithm_mode)
    Returns TRUE if the algorithm is a block algorithm */
 PHP_FUNCTION(mcrypt_module_is_block_algorithm)
 {
-       zval **arg1, **lib_dir;
-       char *lib_dir_s;
-       int argc;
-       
-       argc = ZEND_NUM_ARGS();
-
        MCRYPT_GET_MODE_DIR_ARGS(algorithms_dir)
        
-       if (mcrypt_module_is_block_algorithm (Z_STRVAL_PP(arg1), lib_dir_s) == 0) {
+       if (mcrypt_module_is_block_algorithm (module, dir) == 1) {
                RETURN_TRUE;
-       }
-       else {
+       } else {
                RETURN_FALSE;
        }
 }
@@ -911,18 +879,11 @@ PHP_FUNCTION(mcrypt_module_is_block_algorithm)
    Returns TRUE if the mode outputs blocks of bytes */
 PHP_FUNCTION(mcrypt_module_is_block_mode)
 {
-       zval **arg1, **lib_dir;
-       char *lib_dir_s;
-       int argc;
-       
-       argc = ZEND_NUM_ARGS();
-
        MCRYPT_GET_MODE_DIR_ARGS(modes_dir)
        
-       if (mcrypt_module_is_block_mode (Z_STRVAL_PP(arg1), lib_dir_s) == 0) {
+       if (mcrypt_module_is_block_mode (module, dir) == 1) {
                RETURN_TRUE;
-       }
-       else {
+       } else {
                RETURN_FALSE;
        }
 }
@@ -933,15 +894,9 @@ PHP_FUNCTION(mcrypt_module_is_block_mode)
    Returns the block size of the algorithm */
 PHP_FUNCTION(mcrypt_module_get_algo_block_size)
 {
-       zval **arg1, **lib_dir;
-       char *lib_dir_s;
-       int argc;
-       
-       argc = ZEND_NUM_ARGS();
-
        MCRYPT_GET_MODE_DIR_ARGS(algorithms_dir)
        
-       RETURN_LONG(mcrypt_module_get_algo_block_size (Z_STRVAL_PP(arg1), lib_dir_s))
+       RETURN_LONG(mcrypt_module_get_algo_block_size (module, dir));
 }
 /* }}} */
 
@@ -950,15 +905,9 @@ PHP_FUNCTION(mcrypt_module_get_algo_block_size)
    Returns the maximum supported key size of the algorithm */
 PHP_FUNCTION(mcrypt_module_get_algo_key_size)
 {
-       zval **arg1, **lib_dir;
-       char *lib_dir_s;
-       int argc;
-       
-       argc = ZEND_NUM_ARGS();
-
        MCRYPT_GET_MODE_DIR_ARGS(algorithms_dir);
        
-       RETURN_LONG(mcrypt_module_get_algo_key_size (Z_STRVAL_PP(arg1), lib_dir_s))
+       RETURN_LONG(mcrypt_module_get_algo_key_size (module, dir));
 }
 /* }}} */
 
@@ -967,16 +916,12 @@ PHP_FUNCTION(mcrypt_module_get_algo_key_size)
    This function decrypts the crypttext */
 PHP_FUNCTION(mcrypt_module_get_supported_key_sizes)
 {
-       zval **arg1, **lib_dir;
-       char *lib_dir_s;
        int argc, i, count;
        int *key_sizes;
        
-       argc = ZEND_NUM_ARGS();
-
        MCRYPT_GET_MODE_DIR_ARGS(algorithms_dir)
 
-       key_sizes = mcrypt_module_get_algo_supported_key_sizes (Z_STRVAL_PP(arg1), lib_dir_s, &count);
+       key_sizes = mcrypt_module_get_algo_supported_key_sizes (module, dir, &count);
 
        if (array_init(return_value) == FAILURE) {
                php_error(E_ERROR, "Unable to initialize array");