From 206ffa3fb3fd72c6a2eb45194fb176535a91288c Mon Sep 17 00:00:00 2001 From: xXx-caillou-xXx Date: Thu, 30 Aug 2018 17:14:08 +0200 Subject: Minor code cleanup --- src/sp_unserialize.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/sp_unserialize.c') diff --git a/src/sp_unserialize.c b/src/sp_unserialize.c index 9ed1c55..ab0139a 100644 --- a/src/sp_unserialize.c +++ b/src/sp_unserialize.c @@ -7,7 +7,8 @@ PHP_FUNCTION(sp_serialize) { /* Call the original `serialize` function. */ orig_handler = zend_hash_str_find_ptr( - SNUFFLEUPAGUS_G(sp_internal_functions_hook), "serialize", 9); + SNUFFLEUPAGUS_G(sp_internal_functions_hook), "serialize", + sizeof("serialize") - 1); orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); /* Compute the HMAC of the textual representation of the serialized data*/ @@ -50,6 +51,9 @@ PHP_FUNCTION(sp_unserialize) { size_t buf_len = 0; zval *opts = NULL; + const sp_config_unserialize* config_unserialize = + SNUFFLEUPAGUS_G(config).config_unserialize; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|a", &buf, &buf_len, &opts) == FAILURE) { RETURN_FALSE; @@ -85,16 +89,17 @@ PHP_FUNCTION(sp_unserialize) { if (0 == status) { if ((orig_handler = zend_hash_str_find_ptr( - SNUFFLEUPAGUS_G(sp_internal_functions_hook), "unserialize", 11))) { + SNUFFLEUPAGUS_G(sp_internal_functions_hook), "unserialize", + sizeof("unserialize") - 1))) { orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); } } else { - if (true == SNUFFLEUPAGUS_G(config).config_unserialize->simulation) { + if (true == config_unserialize->simulation) { sp_log_msg("unserialize", SP_LOG_SIMULATION, "Invalid HMAC for %s", serialized_str); if ((orig_handler = zend_hash_str_find_ptr( SNUFFLEUPAGUS_G(sp_internal_functions_hook), "unserialize", - 11))) { + sizeof("unserialize") - 1))) { orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); } } else { @@ -102,10 +107,9 @@ PHP_FUNCTION(sp_unserialize) { serialized_str); } } - if (SNUFFLEUPAGUS_G(config).config_unserialize->dump) { - sp_log_request( - SNUFFLEUPAGUS_G(config).config_unserialize->dump, - SNUFFLEUPAGUS_G(config).config_unserialize->textual_representation, + if (config_unserialize->dump) { + sp_log_request(config_unserialize->dump, + config_unserialize->textual_representation, SP_TOKEN_UNSERIALIZE_HMAC); } efree(serialized_str); -- cgit v1.3