diff options
| author | xXx-caillou-xXx | 2018-07-13 10:36:50 +0200 |
|---|---|---|
| committer | jvoisin | 2018-07-13 08:36:50 +0000 |
| commit | 7963580d72a358975133f86f01de2d2eab08ba38 (patch) | |
| tree | 4bec345d70f687a2a6002b36e2f2fc79318959f6 /src/sp_unserialize.c | |
| parent | 12b740bc7bb01ffe397cecc5b6fa25b136304911 (diff) | |
Massively optimize how rules are handled
This commit does a lot of things:
- Use hashtables instead of lists to store the rules
- Rules that can be applied at launch time won't be tried at runtime
- Improve feedback when writing nonsensical rules
- Make intensive use of `zend_string` instead of `char*`
Diffstat (limited to 'src/sp_unserialize.c')
| -rw-r--r-- | src/sp_unserialize.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/sp_unserialize.c b/src/sp_unserialize.c index 60ef7be..db99389 100644 --- a/src/sp_unserialize.c +++ b/src/sp_unserialize.c | |||
| @@ -18,8 +18,9 @@ PHP_FUNCTION(sp_serialize) { | |||
| 18 | ZVAL_STRING(&func_name, "hash_hmac"); | 18 | ZVAL_STRING(&func_name, "hash_hmac"); |
| 19 | ZVAL_STRING(¶ms[0], "sha256"); | 19 | ZVAL_STRING(¶ms[0], "sha256"); |
| 20 | params[1] = *return_value; | 20 | params[1] = *return_value; |
| 21 | ZVAL_STRING(¶ms[2], | 21 | ZVAL_STRING( |
| 22 | SNUFFLEUPAGUS_G(config).config_snuffleupagus->encryption_key); | 22 | ¶ms[2], |
| 23 | ZSTR_VAL(SNUFFLEUPAGUS_G(config).config_snuffleupagus->encryption_key)); | ||
| 23 | call_user_function(CG(function_table), NULL, &func_name, &hmac, 3, params); | 24 | call_user_function(CG(function_table), NULL, &func_name, &hmac, 3, params); |
| 24 | 25 | ||
| 25 | size_t len = Z_STRLEN_P(return_value) + Z_STRLEN(hmac); | 26 | size_t len = Z_STRLEN_P(return_value) + Z_STRLEN(hmac); |
| @@ -66,8 +67,9 @@ PHP_FUNCTION(sp_unserialize) { | |||
| 66 | zval params[3]; | 67 | zval params[3]; |
| 67 | ZVAL_STRING(¶ms[0], "sha256"); | 68 | ZVAL_STRING(¶ms[0], "sha256"); |
| 68 | ZVAL_STRING(¶ms[1], serialized_str); | 69 | ZVAL_STRING(¶ms[1], serialized_str); |
| 69 | ZVAL_STRING(¶ms[2], | 70 | ZVAL_STRING( |
| 70 | SNUFFLEUPAGUS_G(config).config_snuffleupagus->encryption_key); | 71 | ¶ms[2], |
| 72 | ZSTR_VAL(SNUFFLEUPAGUS_G(config).config_snuffleupagus->encryption_key)); | ||
| 71 | call_user_function(CG(function_table), NULL, &func_name, &expected_hmac, 3, | 73 | call_user_function(CG(function_table), NULL, &func_name, &expected_hmac, 3, |
| 72 | params); | 74 | params); |
| 73 | 75 | ||
| @@ -113,4 +115,4 @@ int hook_serialize(void) { | |||
| 113 | PHP_FN(sp_unserialize)); | 115 | PHP_FN(sp_unserialize)); |
| 114 | 116 | ||
| 115 | return SUCCESS; | 117 | return SUCCESS; |
| 116 | } \ No newline at end of file | 118 | } |
