From 3b547450e5ee6d7bd93f28b44e751ee43936c909 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 3 Jan 2018 13:36:52 +0100 Subject: Remove some dead code --- src/sp_cookie_encryption.c | 2 +- src/sp_disabled_functions.c | 17 +++++------------ src/sp_harden_rand.c | 34 +++++++++++++--------------------- src/sp_unserialize.c | 13 +++---------- 4 files changed, 22 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/sp_cookie_encryption.c b/src/sp_cookie_encryption.c index 6abc20a..42cac85 100644 --- a/src/sp_cookie_encryption.c +++ b/src/sp_cookie_encryption.c @@ -151,7 +151,7 @@ static zend_string *encrypt_data(char *data, unsigned long long data_len) { if (0 == nonce_d) { /* A zend_long should be enough to avoid collisions */ if (php_random_int_throw(0, ZEND_LONG_MAX, &nonce_d) == FAILURE) { - return NULL; + return NULL; // LCOV_EXCL_LINE } } nonce_d++; diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c index 9382b09..829f938 100644 --- a/src/sp_disabled_functions.c +++ b/src/sp_disabled_functions.c @@ -430,19 +430,12 @@ ZEND_FUNCTION(check_disabled_function) { sp_terminate(); } - if ((orig_handler = zend_hash_str_find_ptr( + orig_handler = zend_hash_str_find_ptr( SNUFFLEUPAGUS_G(disabled_functions_hook), current_function_name, - strlen(current_function_name)))) { - orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); - if (true == should_drop_on_ret(return_value, execute_data)) { - sp_terminate(); - } - } else { - sp_log_err( - "disabled_functions", - "Unable to find the pointer to the original function '%s' in the " - "hashtable.\n", - current_function_name); + strlen(current_function_name)); + orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); + if (true == should_drop_on_ret(return_value, execute_data)) { + sp_terminate(); } } diff --git a/src/sp_harden_rand.c b/src/sp_harden_rand.c index b84fbe3..3727bef 100644 --- a/src/sp_harden_rand.c +++ b/src/sp_harden_rand.c @@ -54,34 +54,26 @@ static void random_int_wrapper(INTERNAL_FUNCTION_PARAMETERS) { PHP_FUNCTION(sp_rand) { void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS); - if ((orig_handler = - zend_hash_str_find_ptr(SNUFFLEUPAGUS_G(sp_internal_functions_hook), - "rand", strlen("rand")))) { - /* call the original `rand` function, - * since we might no be the only ones to hook it*/ - orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); - } else { - sp_log_err("harden_rand", - "Unable to find the pointer to the original function 'rand' in " - "the hashtable.\n"); - } + /* call the original `rand` function, + * since we might no be the only ones to hook it*/ + orig_handler = + zend_hash_str_find_ptr(SNUFFLEUPAGUS_G(sp_internal_functions_hook), + "rand", strlen("rand")); + orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); + random_int_wrapper(INTERNAL_FUNCTION_PARAM_PASSTHRU); } PHP_FUNCTION(sp_mt_rand) { void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS); - if ((orig_handler = + /* call the original `mt_rand` function, + * since we might no be the only ones to hook it*/ + orig_handler = zend_hash_str_find_ptr(SNUFFLEUPAGUS_G(sp_internal_functions_hook), - "mt_rand", strlen("mt_rand")))) { - /* call the original `mt_rand` function, - * since we might no be the only ones to hook it*/ - orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); - } else { - sp_log_err("harden_rand", - "Unable to find the pointer to the original function 'mt_rand' " - "in the hashtable.\n"); - } + "mt_rand", strlen("mt_rand")); + orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); + random_int_wrapper(INTERNAL_FUNCTION_PARAM_PASSTHRU); } diff --git a/src/sp_unserialize.c b/src/sp_unserialize.c index 312ba2e..476bebc 100644 --- a/src/sp_unserialize.c +++ b/src/sp_unserialize.c @@ -6,16 +6,9 @@ PHP_FUNCTION(sp_serialize) { void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS); /* Call the original `serialize` function. */ - if ((orig_handler = zend_hash_str_find_ptr( - SNUFFLEUPAGUS_G(sp_internal_functions_hook), "serialize", 9))) { - orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); - } else { - sp_log_err( - "disabled_functions", - "Unable to find the pointer to the original function 'serialize' in " - "the hashtable.\n"); - return; - } + orig_handler = zend_hash_str_find_ptr( + SNUFFLEUPAGUS_G(sp_internal_functions_hook), "serialize", 9); + orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); /* Compute the HMAC of the textual representation of the serialized data*/ zval func_name; -- cgit v1.3