php-src/ext/libxml
Niels Dossche c283c3ab0b Sanitize libxml2 globals before parsing
Fixes GHSA-3qrf-m4j2-pcrr.

To parse a document with libxml2, you first need to create a parsing context.
The parsing context contains parsing options (e.g. XML_NOENT to substitute
entities) that the application (in this case PHP) can set.
Unfortunately, libxml2 also supports providing default set options.
For example, if you call xmlSubstituteEntitiesDefault(1) then the XML_NOENT
option will be added to the parsing options every time you create a parsing
context **even if the application never requested XML_NOENT**.

Third party extensions can override these globals, in particular the
substitute entity global. This causes entity substitution to be
unexpectedly active.

Fix it by setting the parsing options to a sane known value.
For API calls that depend on global state we introduce
PHP_LIBXML_SANITIZE_GLOBALS() and PHP_LIBXML_RESTORE_GLOBALS().
For other APIs that work directly with a context we introduce
php_libxml_sanitize_parse_ctxt_options().
2023-07-31 19:47:19 +01:00
..
tests Try to fix libxml 2.9.12 tests 2021-06-02 12:21:45 +02:00
config.w32 Control VCRT leak reporting via environment variable in debug builds 2020-06-10 09:05:17 +02:00
config0.m4 Normalize comments in *nix build system m4 files 2019-05-12 18:43:03 +02:00
CREDITS
libxml.c xmlRelaxNGCleanupTypes() is deprecated as of libxml2 2.10.0 2022-08-25 15:10:30 +02:00
libxml.stub.php Add missing classes to stubs 2021-02-09 22:38:06 +01:00
libxml_arginfo.h Add missing classes to stubs 2021-02-09 22:38:06 +01:00
php_libxml.h Sanitize libxml2 globals before parsing 2023-07-31 19:47:19 +01:00
php_libxml2.def Add symbol to libxml exports 2017-09-11 17:35:25 +02:00