summaryrefslogtreecommitdiff
path: root/src/sp_unserialize.c
diff options
context:
space:
mode:
authorThibault "bui" Koechlin2017-12-28 17:04:06 +0100
committerjvoisin2017-12-28 17:04:06 +0100
commit9f5e8d12f05fb24c915a5266a1e908a75c8aed08 (patch)
tree9160075ea943c7fd29a3923f844a0ac0d6b8b457 /src/sp_unserialize.c
parent62c48bf9a85e0294b7b32cea438e904e1cd50669 (diff)
Clang-format pass
- `clang-format --style="{BasedOnStyle: google, SortIncludes: false}" -i snuffleu*.c sp_*.c sp_*.h` - Update the documentation accordingly
Diffstat (limited to 'src/sp_unserialize.c')
-rw-r--r--src/sp_unserialize.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/sp_unserialize.c b/src/sp_unserialize.c
index 7f3add0..312ba2e 100644
--- a/src/sp_unserialize.c
+++ b/src/sp_unserialize.c
@@ -6,11 +6,12 @@ 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(SNUFFLEUPAGUS_G(sp_internal_functions_hook), 9 if ((orig_handler = zend_hash_str_find_ptr(
10 "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 { 12 } else {
13 sp_log_err("disabled_functions", 13 sp_log_err(
14 "disabled_functions",
14 "Unable to find the pointer to the original function 'serialize' in " 15 "Unable to find the pointer to the original function 'serialize' in "
15 "the hashtable.\n"); 16 "the hashtable.\n");
16 return; 17 return;
@@ -57,7 +58,8 @@ PHP_FUNCTION(sp_unserialize) {
57 58
58 /* 64 is the length of HMAC-256 */ 59 /* 64 is the length of HMAC-256 */
59 if (buf_len < 64) { 60 if (buf_len < 64) {
60 sp_log_msg("unserialize", SP_LOG_DROP, "The serialized object is too small."); 61 sp_log_msg("unserialize", SP_LOG_DROP,
62 "The serialized object is too small.");
61 RETURN_FALSE; 63 RETURN_FALSE;
62 } 64 }
63 65
@@ -82,19 +84,22 @@ PHP_FUNCTION(sp_unserialize) {
82 } 84 }
83 85
84 if (0 == status) { 86 if (0 == status) {
85 if ((orig_handler = zend_hash_str_find_ptr(SNUFFLEUPAGUS_G(sp_internal_functions_hook), 87 if ((orig_handler = zend_hash_str_find_ptr(
86 "unserialize", 11))) { 88 SNUFFLEUPAGUS_G(sp_internal_functions_hook), "unserialize", 11))) {
87 orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); 89 orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU);
88 } 90 }
89 } else { 91 } else {
90 if ( true == SNUFFLEUPAGUS_G(config).config_unserialize->simulation) { 92 if (true == SNUFFLEUPAGUS_G(config).config_unserialize->simulation) {
91 sp_log_msg("unserialize", SP_LOG_SIMULATION, "Invalid HMAC for %s", serialized_str); 93 sp_log_msg("unserialize", SP_LOG_SIMULATION, "Invalid HMAC for %s",
92 if ((orig_handler = zend_hash_str_find_ptr(SNUFFLEUPAGUS_G(sp_internal_functions_hook), 94 serialized_str);
93 "unserialize", 11))) { 95 if ((orig_handler = zend_hash_str_find_ptr(
96 SNUFFLEUPAGUS_G(sp_internal_functions_hook), "unserialize",
97 11))) {
94 orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); 98 orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU);
95 } 99 }
96 } else { 100 } else {
97 sp_log_msg("unserialize", SP_LOG_DROP, "Invalid HMAC for %s", serialized_str); 101 sp_log_msg("unserialize", SP_LOG_DROP, "Invalid HMAC for %s",
102 serialized_str);
98 } 103 }
99 } 104 }
100 efree(serialized_str); 105 efree(serialized_str);
@@ -104,8 +109,10 @@ PHP_FUNCTION(sp_unserialize) {
104int hook_serialize(void) { 109int hook_serialize(void) {
105 TSRMLS_FETCH(); 110 TSRMLS_FETCH();
106 111
107 HOOK_FUNCTION("serialize", sp_internal_functions_hook, PHP_FN(sp_serialize), false); 112 HOOK_FUNCTION("serialize", sp_internal_functions_hook, PHP_FN(sp_serialize),
108 HOOK_FUNCTION("unserialize", sp_internal_functions_hook, PHP_FN(sp_unserialize), false); 113 false);
114 HOOK_FUNCTION("unserialize", sp_internal_functions_hook,
115 PHP_FN(sp_unserialize), false);
109 116
110 return SUCCESS; 117 return SUCCESS;
111} 118}