diff options
| author | Ben Fuhrmannek | 2021-02-16 11:16:59 +0100 |
|---|---|---|
| committer | Ben Fuhrmannek | 2021-02-16 11:16:59 +0100 |
| commit | 5484bcb5eb2714e7438927e2566c86a74d7c51af (patch) | |
| tree | b78326d2999397be4c08e06b23209981f82a4ea9 /src/sp_disable_xxe.c | |
| parent | 7ac1e3866ef4f146c6c93a5ca13b9aebb14e936a (diff) | |
| parent | cecfdd808da67be908dbe7144cc8c74dfb3f855e (diff) | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/sp_disable_xxe.c')
| -rw-r--r-- | src/sp_disable_xxe.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/sp_disable_xxe.c b/src/sp_disable_xxe.c index 53148c8..113d84b 100644 --- a/src/sp_disable_xxe.c +++ b/src/sp_disable_xxe.c | |||
| @@ -3,18 +3,21 @@ | |||
| 3 | PHP_FUNCTION(sp_libxml_disable_entity_loader) { RETURN_TRUE; } | 3 | PHP_FUNCTION(sp_libxml_disable_entity_loader) { RETURN_TRUE; } |
| 4 | 4 | ||
| 5 | int hook_libxml_disable_entity_loader() { | 5 | int hook_libxml_disable_entity_loader() { |
| 6 | zval func_name; | ||
| 7 | zval hmac; | ||
| 8 | zval params[1]; | ||
| 9 | |||
| 10 | TSRMLS_FETCH(); | 6 | TSRMLS_FETCH(); |
| 11 | 7 | ||
| 8 | // External entities are disabled by default in PHP8+ | ||
| 9 | #if PHP_VERSION_ID < 80000 | ||
| 12 | /* Call the php function here instead of re-implementing it is a bit | 10 | /* Call the php function here instead of re-implementing it is a bit |
| 13 | * ugly, but we do not want to introduce compile-time dependencies against | 11 | * ugly, but we do not want to introduce compile-time dependencies against |
| 14 | * libxml. */ | 12 | * libxml. */ |
| 13 | zval func_name; | ||
| 14 | zval hmac; | ||
| 15 | zval params[1]; | ||
| 16 | |||
| 15 | ZVAL_STRING(&func_name, "libxml_disable_entity_loader"); | 17 | ZVAL_STRING(&func_name, "libxml_disable_entity_loader"); |
| 16 | ZVAL_STRING(¶ms[0], "true"); | 18 | ZVAL_STRING(¶ms[0], "true"); |
| 17 | call_user_function(CG(function_table), NULL, &func_name, &hmac, 1, params); | 19 | call_user_function(CG(function_table), NULL, &func_name, &hmac, 1, params); |
| 20 | #endif | ||
| 18 | 21 | ||
| 19 | HOOK_FUNCTION("libxml_disable_entity_loader", sp_internal_functions_hook, | 22 | HOOK_FUNCTION("libxml_disable_entity_loader", sp_internal_functions_hook, |
| 20 | PHP_FN(sp_libxml_disable_entity_loader)); | 23 | PHP_FN(sp_libxml_disable_entity_loader)); |
