summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/sp_cookie_encryption.c2
-rw-r--r--src/sp_disabled_functions.c17
-rw-r--r--src/sp_harden_rand.c34
-rw-r--r--src/sp_unserialize.c13
4 files changed, 22 insertions, 44 deletions
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) {
151 if (0 == nonce_d) { 151 if (0 == nonce_d) {
152 /* A zend_long should be enough to avoid collisions */ 152 /* A zend_long should be enough to avoid collisions */
153 if (php_random_int_throw(0, ZEND_LONG_MAX, &nonce_d) == FAILURE) { 153 if (php_random_int_throw(0, ZEND_LONG_MAX, &nonce_d) == FAILURE) {
154 return NULL; 154 return NULL; // LCOV_EXCL_LINE
155 } 155 }
156 } 156 }
157 nonce_d++; 157 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) {
430 sp_terminate(); 430 sp_terminate();
431 } 431 }
432 432
433 if ((orig_handler = zend_hash_str_find_ptr( 433 orig_handler = zend_hash_str_find_ptr(
434 SNUFFLEUPAGUS_G(disabled_functions_hook), current_function_name, 434 SNUFFLEUPAGUS_G(disabled_functions_hook), current_function_name,
435 strlen(current_function_name)))) { 435 strlen(current_function_name));
436 orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); 436 orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU);
437 if (true == should_drop_on_ret(return_value, execute_data)) { 437 if (true == should_drop_on_ret(return_value, execute_data)) {
438 sp_terminate(); 438 sp_terminate();
439 }
440 } else {
441 sp_log_err(
442 "disabled_functions",
443 "Unable to find the pointer to the original function '%s' in the "
444 "hashtable.\n",
445 current_function_name);
446 } 439 }
447} 440}
448 441
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) {
54PHP_FUNCTION(sp_rand) { 54PHP_FUNCTION(sp_rand) {
55 void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS); 55 void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS);
56 56
57 if ((orig_handler = 57 /* call the original `rand` function,
58 zend_hash_str_find_ptr(SNUFFLEUPAGUS_G(sp_internal_functions_hook), 58 * since we might no be the only ones to hook it*/
59 "rand", strlen("rand")))) { 59 orig_handler =
60 /* call the original `rand` function, 60 zend_hash_str_find_ptr(SNUFFLEUPAGUS_G(sp_internal_functions_hook),
61 * since we might no be the only ones to hook it*/ 61 "rand", strlen("rand"));
62 orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); 62 orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU);
63 } else { 63
64 sp_log_err("harden_rand",
65 "Unable to find the pointer to the original function 'rand' in "
66 "the hashtable.\n");
67 }
68 random_int_wrapper(INTERNAL_FUNCTION_PARAM_PASSTHRU); 64 random_int_wrapper(INTERNAL_FUNCTION_PARAM_PASSTHRU);
69} 65}
70 66
71PHP_FUNCTION(sp_mt_rand) { 67PHP_FUNCTION(sp_mt_rand) {
72 void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS); 68 void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS);
73 69
74 if ((orig_handler = 70 /* call the original `mt_rand` function,
71 * since we might no be the only ones to hook it*/
72 orig_handler =
75 zend_hash_str_find_ptr(SNUFFLEUPAGUS_G(sp_internal_functions_hook), 73 zend_hash_str_find_ptr(SNUFFLEUPAGUS_G(sp_internal_functions_hook),
76 "mt_rand", strlen("mt_rand")))) { 74 "mt_rand", strlen("mt_rand"));
77 /* call the original `mt_rand` function, 75 orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU);
78 * since we might no be the only ones to hook it*/ 76
79 orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU);
80 } else {
81 sp_log_err("harden_rand",
82 "Unable to find the pointer to the original function 'mt_rand' "
83 "in the hashtable.\n");
84 }
85 random_int_wrapper(INTERNAL_FUNCTION_PARAM_PASSTHRU); 77 random_int_wrapper(INTERNAL_FUNCTION_PARAM_PASSTHRU);
86} 78}
87 79
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) {
6 void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS); 6 void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS);
7 7
8 /* Call the original `serialize` function. */ 8 /* Call the original `serialize` function. */
9 if ((orig_handler = zend_hash_str_find_ptr( 9 orig_handler = zend_hash_str_find_ptr(
10 SNUFFLEUPAGUS_G(sp_internal_functions_hook), "serialize", 9))) { 10 SNUFFLEUPAGUS_G(sp_internal_functions_hook), "serialize", 9);
11 orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); 11 orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU);
12 } else {
13 sp_log_err(
14 "disabled_functions",
15 "Unable to find the pointer to the original function 'serialize' in "
16 "the hashtable.\n");
17 return;
18 }
19 12
20 /* Compute the HMAC of the textual representation of the serialized data*/ 13 /* Compute the HMAC of the textual representation of the serialized data*/
21 zval func_name; 14 zval func_name;