summaryrefslogtreecommitdiff
path: root/src/sp_disable_xxe.c
diff options
context:
space:
mode:
authorSebastien Blot2017-09-20 10:11:01 +0200
committerSebastien Blot2017-09-20 10:11:01 +0200
commit868f96c759b6650d88ff9f4fbc5c048302134248 (patch)
treec0de0af318bf77a8959164ef11aeeeb2b7bab294 /src/sp_disable_xxe.c
Initial import
Diffstat (limited to 'src/sp_disable_xxe.c')
-rw-r--r--src/sp_disable_xxe.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/sp_disable_xxe.c b/src/sp_disable_xxe.c
new file mode 100644
index 0000000..d11b3d0
--- /dev/null
+++ b/src/sp_disable_xxe.c
@@ -0,0 +1,25 @@
1#include "php_snuffleupagus.h"
2
3ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
4
5PHP_FUNCTION(sp_libxml_disable_entity_loader) { RETURN_TRUE; }
6
7int hook_libxml_disable_entity_loader() {
8 zval func_name;
9 zval hmac;
10 zval params[1];
11
12 TSRMLS_FETCH();
13
14 /* Call the php function here instead of re-implementing it is a bit
15 * ugly, but we do not want to introduce compile-time dependencies against
16 * libxml. */
17 ZVAL_STRING(&func_name, "libxml_disable_entity_loader");
18 ZVAL_STRING(&params[0], "true");
19 call_user_function(CG(function_table), NULL, &func_name, &hmac, 1, params);
20
21 HOOK_FUNCTION("libxml_disable_entity_loader", sp_internal_functions_hook,
22 PHP_FN(sp_libxml_disable_entity_loader), false);
23
24 return SUCCESS;
25}