1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-25 23:21:26 +03:00
Commit Graph

25 Commits

Author SHA1 Message Date
Nick Wellnhofer
209516acbf tests: Don't use deprecated symbols 2023-09-20 22:06:49 +02:00
Nick Wellnhofer
5aff27ae78 parser: Optimize xmlLoadEntityContent
Load entity content via xmlParserInputBufferGrow, avoiding a copy.

This also fixes an entity size accounting error.
2023-08-08 15:21:25 +02:00
Nick Wellnhofer
886bf4e63b Stop calling xmlMemoryDump
This was used to check for memory leaks but could potentially create a
.memdump file. These days, there are better ways to check for memory
leaks.
2023-04-30 15:48:41 +02:00
Nick Wellnhofer
3f69fc805c parser: Tighten expansion limits
- Lower the amount of expansion which is always allowed from
  10MB to 1MB.
- Lower the maximum amplification factor from 10 to 5.
- Lower the "fixed cost" from 50 to 20.
2023-03-08 13:58:49 +01:00
Nick Wellnhofer
cfc036bda8 testrecurse: Test parameter entity accounting 2022-12-21 20:35:31 +01:00
Nick Wellnhofer
106c4cdd4b testrecurse: Support multiple huge docs 2022-12-21 20:21:51 +01:00
Nick Wellnhofer
079da5b26d testrecurse: Add external entities to huge test 2022-12-21 20:21:51 +01:00
Nick Wellnhofer
01bcb23de1 testrecurse: Add test cases for external entities
Add test cases for external general and parameter entities.
2022-12-21 20:21:51 +01:00
Nick Wellnhofer
69aeff53c1 testrecurse: Also test without entity substitution 2022-12-21 20:20:11 +01:00
Nick Wellnhofer
4c7cb8f4d4 testrecurse: Also test SAX parser 2022-12-21 20:20:11 +01:00
Nick Wellnhofer
583cd2f64b testrecurse: Start to test entity expansion stats 2022-12-21 20:19:10 +01:00
Nick Wellnhofer
463bbeeca1 entities: Rework entity amplification checks
This commit implements robust detection of entity amplification attacks,
better known as the "billion laughs" attack.

We now limit the size of the document after substitution of entities to
10 times the size before expansion. This guarantees linear behavior by
definition. There already was a similar check before, but the accounting
of "sizeentities" (size of external entities) and "sizeentcopy" (size of
all copies created by entity references) wasn't accurate.

We also need saturation arithmetic since we're historically limited to
"unsigned long" which is 32-bit on many platforms.

A maximum of 10 MB of substitutions is always allowed. This should make
use cases like DITA work which have caused problems in the past.

The old checks based on the number of entities were removed. This is
accounted for by adding a fixed cost to each entity reference.

Entity amplification checks are now enabled even if XML_PARSE_HUGE is
set. This option is mainly used to allow larger text nodes. Most users
were unaware that it also disabled entity expansion checks.

Some of the limits might be adjusted later. If this change turns out to
affect legitimate use cases, we can add a separate parser option to
disable the checks.

Fixes #294.
Fixes #345.
2022-12-21 20:19:10 +01:00
Nick Wellnhofer
dd3569eaa5 Remove XMLDECL macro from .c files 2022-12-08 02:43:17 +01:00
Nick Wellnhofer
34a5a4a5e5 tests: Remove unneeded #includes 2022-11-22 16:03:05 +01:00
Nick Wellnhofer
5bffa33a12 Stop including sys/types.h 2022-09-02 18:33:36 +02:00
Nick Wellnhofer
2489c1d024 Remove useless __CYGWIN__ checks
From what I can tell, some really early Cygwin versions from around
1998-2000 used to erroneously define _WIN32. This was eventually fixed,
but these days, the `defined(_WIN32) && !defined(__CYGWIN__)` idiom is
unnecessary.

Now, we only check for __CYGWIN__ in xmlexports.h when deciding whether
to use __declspec.
2022-02-28 22:58:35 +01:00
Jared Yanovich
2a350ee9b4 Large batch of typo fixes
Closes #109.
2019-09-30 18:04:38 +02:00
Nick Wellnhofer
8919885ff9 Fix -Wformat-truncation warnings (GCC 8) 2019-01-06 14:24:59 +01:00
Nick Wellnhofer
154824ee5e Fix unused variable warnings in testrecurse 2017-10-21 14:10:11 +02:00
Roumen Petrov
c3b1d09ba2 clean redefinition of {v}snprintf in C-source
as those from *config.h are preferable (e.g. win32config.h)
2012-08-13 16:57:30 +08:00
Roumen Petrov
1f0453f715 minimize use of HAVE_CONFIG_H
as build process for supported platforms provide "config.h" header file
2012-08-13 16:57:30 +08:00
Daniel Veillard
b60e612e87 Small cleanup of unused variables in test 2012-07-23 14:24:27 +08:00
Daniel Veillard
22030ef888 Restore code for Windows compilation
Try to keep as close to rc1 but still allow the change from Roumen for
mingw
2012-05-23 15:52:45 +08:00
Roumen Petrov
978ff224b2 use mingw C99 compatible functions {v}snprintf instead those from MSVC runtime 2012-05-21 10:20:09 +08:00
Daniel Veillard
0161e638c6 completely different fix for the recursion detection based on entity
* parser.c include/libxml/parser.h: completely different fix for
  the recursion detection based on entity density, big cleanups
  in the entity parsing code too
* result/*.sax*: the parser should not ask for used defined versions
  of the predefined entities
* testrecurse.c: automatic test for entity recursion checks
* Makefile.am: added testrecurse
* test/recurse/lol* test/recurse/good*: a first set of tests for
  the recursion
Daniel

svn path=/trunk/; revision=3783
2008-08-28 15:36:32 +00:00