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

5563 Commits

Author SHA1 Message Date
Nick Wellnhofer
b6f1298ae7 warnings: Remove set-but-unused variables
Fixes compiler warnings with clang 15.
2022-10-25 19:34:38 +02:00
Nick Wellnhofer
bffc67d15c threads: Remove check for pthread_equal
GCC 12 fixed -Waddress warnings for inline functions, resulting in
warnings when comparing pthread_equal with NULL. Simply remove the
check and assume that pthread_equal is available if all the other
functions are. This code is only enabled on Linux anyway.
2022-10-25 19:34:38 +02:00
Nick Wellnhofer
20e2fb4c1c xinclude: Avoid creation of subcontexts
Don't create subcontext in xmlXIncludeRecurseDoc. Save and restore 'doc'
and 'incTab' instead.

Make xmlXIncludeLoadFallback call xmlXIncludeCopyNode which seems safer
than xmlXIncludeDoProcess since the latter may modify the document.
This should also be more performant since we need to copy the whole
fallback subtree anyway. Also make sure to avoid replacements in
fallback elements in xmlXIncludeDoProcess.
2022-10-25 19:34:38 +02:00
Nick Wellnhofer
010b682fee xinclude: Rework XInclude cache
Use a single cache stored in the "root" context, avoiding cache misses
in some scenarios. Separate the cache from the "include" table. Rework
recursion check.
2022-10-23 18:55:10 +02:00
Nick Wellnhofer
3b68aa4753 xinclude: Remove unused 'doc' argument from xmlXIncludeDoProcess 2022-10-23 18:55:10 +02:00
Nick Wellnhofer
0b09f132f4 xinclude: Remove unused member 'url' from xmlXIncludeCtxt 2022-10-23 18:52:56 +02:00
Nick Wellnhofer
966f5ebd77 xinclude: Remove inefficient refcounting scheme
xinclude.c used to implement a refcounting mechanism for documents which
could result in documents being freed too early and reloaded. We really
should keep parsed and processed documents around for as long as
possible to avoid reprocessing.
2022-10-23 18:52:56 +02:00
Nick Wellnhofer
fe0194d56f xinlucde: Pass xmlXIncludeRefPtrs directly
Stop passing indices into the include table.
2022-10-23 18:52:56 +02:00
Nick Wellnhofer
0fc5be0ad1 xinclude: Remove dead code in xmlXIncludeLoadDoc
The include table was already scanned for entries with a matching URI a
couple of lines before.
2022-10-23 18:52:56 +02:00
Nick Wellnhofer
2fc8d12327 xinclude: Make xmlXIncludeCopyNode non-recursive
Avoid call stack overflows.

Also switch to xmlStaticCopyNode which avoids duplicate namespace
definitions.
2022-10-23 18:52:56 +02:00
Nick Wellnhofer
bc32c3862c xinclude: Don't pass documents to xmlXIncludeCopyNode
Extract the root element directly in xmlXIncludeCopyXPointer.
2022-10-23 18:52:56 +02:00
Nick Wellnhofer
46e4cfb643 xinclude: Remove unused source and target arguments
source is unused, target is always ctxt->doc.
2022-10-23 18:52:56 +02:00
Nick Wellnhofer
d2ed1e4f99 xinclude: Limit recursion depth
This avoids call stack overflows.
2022-10-23 18:52:56 +02:00
Nick Wellnhofer
34496f26db xinclude: Test for inclusion loops 2022-10-23 14:27:05 +02:00
Nick Wellnhofer
bad30e2b2e xinclude: Copy included docs with xmlDocCopyNode
All includes should already be expanded after calling
xmlXIncludeRecurseDoc, so there's no need to invoke the more costly
xmlXIncludeCopyNodeList. Now xmlXIncludeCopyNode is only used to copy
XPointer fragments.
2022-10-23 14:27:05 +02:00
Nick Wellnhofer
bc267cb9bc xinclude: Expand includes in xmlXIncludeCopyNode
This should make nested includes work reliably.

Fixes #424.
2022-10-23 14:27:05 +02:00
Nick Wellnhofer
5e4b751f32 xinclude: Make xmlXIncludeCopyNode return a node list
Convert callers of xmlXIncludeCopyNode to handle node lists.
2022-10-23 14:27:05 +02:00
Nick Wellnhofer
64eaf4d429 xinclude: Make xmlXIncludeCopyNode iterate all descendants 2022-10-23 14:27:05 +02:00
Nick Wellnhofer
5f664ab2cf xinclude: Rework xmlXIncludePreProcessNode
Rename xmlXIncludePreProcessNode to xmlXIncludeExpandNode.

Search the include table for an already existing entry. Also load the
included items in xmlXIncludeExpandNode and remove the second phase in
xmlXIncludeDoProcess.
2022-10-23 14:27:05 +02:00
Nick Wellnhofer
4d7524af7f xinclude: Ignore XML_XINCLUDE_START in xmlXIncludeCopyXPointer
The XPath engine shouldn't return such nodes anyway.
2022-10-23 14:27:05 +02:00
Nick Wellnhofer
ea7c9fb5dd xinclude: Don't create result doc for test with errors 2022-10-23 14:27:05 +02:00
Nick Wellnhofer
c99cde3f21 xinclude: Also test error messages
The reader interface with XIncludes is somewhat broken and can generate
different error messages. Start to move tests which are sketchy with
reader to a separate directory.
2022-10-23 14:26:59 +02:00
Nick Wellnhofer
938105b572 Revert "xinclude: Fix regression with nested includes"
This reverts commit 7f04e29731 which
caused memory errors.

See #424.
2022-10-21 15:56:12 +02:00
Nick Wellnhofer
e85f9b98a5 xmllint: Improve handling of empty XPath node sets
Don't return an error if the result is an empty node set. Suppress the
"XPath set is empty" message in quiet mode.

Fixes #180.
2022-10-19 02:51:14 +02:00
Nick Wellnhofer
530938b487 cmake: Build static library with -DLIBXML_STATIC
Fix scope of target_compile_definitions command.

Fixes #425.
2022-10-18 19:17:45 +02:00
Nick Wellnhofer
7f04e29731 xinclude: Fix regression with nested includes
This reverts commits 74dcc10b and 87d20b55.

Fixes #424.
2022-10-18 19:17:45 +02:00
Nick Wellnhofer
644a89e080 [CVE-2022-40304] Fix dict corruption caused by entity reference cycles
When an entity reference cycle is detected, the entity content is
cleared by setting its first byte to zero. But the entity content might
be allocated from a dict. In this case, the dict entry becomes corrupted
leading to all kinds of logic errors, including memory errors like
double-frees.

Stop storing entity content, orig, ExternalID and SystemID in a dict.
These values are unlikely to occur multiple times in a document, so they
shouldn't have been stored in a dict in the first place.

Thanks to Ned Williamson and Nathan Wachholz working with Google Project
Zero for the report!
2022-10-14 15:02:06 +02:00
Nick Wellnhofer
ffaec75809 Fix integer overflows with XML_PARSE_HUGE
Also impose size limits when XML_PARSE_HUGE is set. Limit size of names
to XML_MAX_TEXT_LENGTH (10 million bytes) and other content to
XML_MAX_HUGE_LENGTH (1 billion bytes).

Move some the length checks to the end of the respective loop to make
them strict.

xmlParseEntityValue didn't have a length limitation at all. But without
XML_PARSE_HUGE, this should eventually trigger an error in xmlGROW.

Thanks to Maddie Stone working with Google Project Zero for the report!
2022-10-14 15:01:46 +02:00
Nick Wellnhofer
1a2d8ddc06 parser: Fix potential memory leak in xmlParseAttValueInternal
Fix memory leak in case xmlParseAttValueInternal is called with a NULL
`len` a non-NULL `alloc` argument. This static function is never called
with such arguments internally, but the misleading code should be fixed
nevertheless.

Fixes #422.
2022-10-11 13:14:37 +02:00
Nick Wellnhofer
5bfaf23059 win32: Fix build with VS2013
Should fix #420.
2022-10-11 13:00:33 +02:00
Nick Wellnhofer
e2bae1bc04 autotools: Don't use version script on Windows
A feature test would be better, but blacklisting Windows platforms seems
good enough for now.
2022-09-20 14:39:52 +02:00
Nick Wellnhofer
796c830a2f cmake: Set SOVERSION
Fixes #410.
2022-09-20 14:30:19 +02:00
Nick Wellnhofer
1d4f5d24ac schemas: Fix null-pointer-deref in xmlSchemaCheckCOSSTDerivedOK
Found by OSS-Fuzz.
2022-09-13 16:56:59 +02:00
Nick Wellnhofer
f2392dc464 gitlab-ci: Allow cast-align warnings from clang 2022-09-09 14:03:01 +02:00
Nick Wellnhofer
a9669679f5 error: Don't use initGenericErrorDefaultFunc
The code in xmlInitParser did only set the error handler if it was NULL
which should never happen.
2022-09-09 13:52:48 +02:00
Nick Wellnhofer
27c8ba6054 xpath: Lower XPath recursion limit on Windows 2022-09-07 22:34:42 +02:00
Nick Wellnhofer
f597eff8dd autotools: Fix winsock detection
Hardcode the required library on MinGW because winsock uses non-standard
calling conventions on 32-bit Windows which makes AC_SEARCH_LIBS fail.

Should fix #406.
2022-09-07 18:26:44 +02:00
Nick Wellnhofer
16d3e8b239 autotools: Only add network libraries if HTTP/FTP enabled 2022-09-07 18:10:03 +02:00
Nick Wellnhofer
ae98a5b47e gitlab-ci: Fix tar invocation 2022-09-07 12:12:45 +02:00
Nick Wellnhofer
c52dd49473 gitlab-ci: Move MSVC test to separate script 2022-09-06 23:27:01 +02:00
Nick Wellnhofer
ea78427dca gitlab-ci: Fix SUFFIX, remove MINGW_PATH 2022-09-06 22:46:07 +02:00
Nick Wellnhofer
e4bdbf3ddb gitlab-ci: Consolidate CMake test scripts 2022-09-06 21:37:17 +02:00
Nick Wellnhofer
861466bf4e gitlab-ci: Only install MinGW autotools if needed 2022-09-06 20:32:08 +02:00
Nick Wellnhofer
5ff3baf0dc python: Create .pyd on Windows 2022-09-06 19:33:32 +02:00
Nick Wellnhofer
e86ede09d4 gitlab-ci: Only install cmake MinGW package if needed
On MinGW, cmake requires curl which requires nghttp2 which requires
libxml2. But having a system libxml2 interferes with the Python tests
for now. Ultimately, we should use Python's os.add_dll_directory() on
Windows. I'm not sure why the current solution using PATH even works.
2022-09-06 19:33:32 +02:00
Nick Wellnhofer
7ab3228f21 gitlab-ci: Install 7-Zip using the .msi
So we don't need cmake to extract a file.
2022-09-06 19:33:32 +02:00
Nick Wellnhofer
fec85df14d xmllint: Document --quiet option 2022-09-06 19:33:32 +02:00
Nick Wellnhofer
ea8f7c92a9 autotools: Disable parallel Python build
Makefile rules with multiple output files don't work reliably with
parallel builds. There are several ways to fix this issue with GNU Make,
but they aren't portable. I'd be really interested in a totally
reliable, cross-platform solution to this problem.

.NOTPARALLEL is also understood by BSD make, at least.
2022-09-06 01:07:24 +02:00
Nick Wellnhofer
9d19c169bb python: Don't output missing generators during build 2022-09-06 01:07:24 +02:00
Nick Wellnhofer
a41878bd4c build: Remove check for broken ss_family
This only seemed to affect ancient AIX systems.
2022-09-06 01:07:24 +02:00