1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-04-22 10:50:08 +03:00

5903 Commits

Author SHA1 Message Date
Nick Wellnhofer
e4f56a7213 parser: Simplify xmlParseConditionalSections 2022-11-20 21:16:03 +01:00
Nick Wellnhofer
3582b07bd2 parser: Fix content parser progress checks
This is another attempt at fixing parser progress checks. Instead of
relying on in->consumed, which could overflow, change some content
parser functions to make guaranteed progress on certain byte sequences.
2022-11-20 21:16:03 +01:00
Nick Wellnhofer
f7ad338e09 parser: Fix attribute parser progress checks
This is another attempt at fixing parser progress checks. Instead of
relying on in->consumed, which could overflow, make the attribute parser
functions return a NULL name only if they don't make progress.
2022-11-20 21:16:03 +01:00
Nick Wellnhofer
f61b8a6233 parser: Fix DTD parser progress checks
This is another attempt at fixing parser progress checks. Instead of
relying on in->consumed, which could overflow, change some DTD parser
functions to make guaranteed progress on certain byte sequences.
2022-11-20 21:16:03 +01:00
Nick Wellnhofer
249cee4b2a io: Fix a few integer overflows in I/O statistics
There are still many places where arithmetic on "consumed" stats isn't
checked for overflow, affecting platforms with a 32-bit long type.
2022-11-20 21:16:03 +01:00
Nick Wellnhofer
6b57061909 io: Rearrange code in xmlSwitchInputEncodingInt
No functional change.
2022-11-20 21:16:03 +01:00
Nick Wellnhofer
1ef4938fd0 io: Rework xmlParserInputBufferGrow with encodings
Read data directly into the "raw" buffer when converting encodings.
Make sure not to grow memory input buffers.
2022-11-20 21:16:03 +01:00
Nick Wellnhofer
46cd7d224e io: Remove xmlInputReadCallbackNop
In some cases, for example when using encoders, the read callback was
set to NULL, in other cases it was set to xmlInputReadCallbackNop.
xmlGROW only tested for xmlInputReadCallbackNop, resulting in errors
when parsing large encoded content from memory.

Always use a NULL callback for memory buffers to avoid ambiguities.

Fixes #262.
2022-11-20 21:12:18 +01:00
Nick Wellnhofer
9feafbc5c5 io: Check for memory buffer early in xmlParserInputGrow 2022-11-13 18:08:34 +01:00
Nick Wellnhofer
22d879bf0a io: Fix "buffer full" error with certain buffer sizes
Remove a useless check in xmlParserInputBufferGrow that could be
triggered after changing xmlBufAvail in c14cac8b.

Fixes #438.
2022-11-13 15:21:22 +01:00
Nick Wellnhofer
0d1765fdb7 doc: Mention new location of XML catalog as breaking change 2022-11-13 15:21:22 +01:00
Nick Wellnhofer
a249372112 doc: Mention potentially breaking changes in NEWS 2022-11-04 15:10:48 +01:00
Nick Wellnhofer
b693905f9b doc: Remove xmlDllMain from documentation and version script
This is a Windows-only symbol.
2022-11-04 14:50:39 +01:00
Nick Wellnhofer
d48faf1a7d doc: Mention ${sysconfdir} in man pages
Fixes #395.
2022-11-04 14:35:34 +01:00
Nick Wellnhofer
3ab57bf475 doc: Document xmlcatalog --convert
Fixes #417.
2022-11-04 14:35:33 +01:00
Nick Wellnhofer
ae7096a173 doc: Document xmllint --nodict and --pedantic
Fixes #418.
2022-11-04 14:35:33 +01:00
Nick Wellnhofer
736487dffb doc: Fix indentation in source XML files 2022-11-04 14:35:33 +01:00
Nick Wellnhofer
a70f7d4715 parser: Fix error message in xmlParseCommentComplex
Fixes #421.
2022-11-04 14:03:31 +01:00
Markus Jörg
1fa4d14fbe Bypass proxy in nanoHTTP for hosts in "no_proxy" 2022-11-04 12:34:39 +00:00
Nick Wellnhofer
b45927095e malloc-fail: Fix memory leak in xmlStringGetNodeList
Also make sure to return NULL on error instead of a partial node list.

Found with libFuzzer, see #344.
2022-11-02 16:22:54 +01:00
Nick Wellnhofer
5a19e21605 malloc-fail: Fix use-after-free in xmlXIncludeAddNode
Found with libFuzzer, see #344.
2022-11-02 16:13:27 +01:00
Nick Wellnhofer
afc7e3a7f4 malloc-fail: Fix memory leak in xmlParseReference
Found with libFuzzer, see #344.
2022-11-02 16:11:00 +01:00
Nick Wellnhofer
7ceaee9430 malloc-fail: Fix memory leak in xmlSAX2ExternalSubset
Found with libFuzzer, see #344.
2022-11-02 16:05:05 +01:00
Nick Wellnhofer
e129c1d1a2 malloc-fail: Fix infinite loop in xmlSkipBlankChars
Found with libFuzzer, see #344.
2022-11-02 16:02:39 +01:00
Nick Wellnhofer
dd50cfeb61 malloc-fail: Fix memory leak in xmlNewDocNodeEatName
Found with libFuzzer, see #344.
2022-11-02 15:58:31 +01:00
Nick Wellnhofer
fa361de0b7 malloc-fail: Fix memory leak in xmlNewPropInternal
Also fixes a memory leak if called with a non-element node.

Found with libFuzzer, see #344.
2022-11-02 15:57:54 +01:00
Nick Wellnhofer
865e142c41 malloc-fail: Fix memory leak in xmlCreatePushParserCtxt
Found with libFuzzer, see #344.
2022-11-02 15:57:53 +01:00
Nick Wellnhofer
a22bd982bf malloc-fail: Fix memory leak in xmlStaticCopyNodeList
Found with libFuzzer, see #344.
2022-11-02 15:57:53 +01:00
Nick Wellnhofer
abb5a93fed schemas: Fix infinite loop in xmlSchemaCheckElemSubstGroup
Types like xmlSchemaTypeAnyTypeDef have a base type pointing to itself,
resulting in an infinite loop.

Fixes #430.
2022-11-02 10:55:29 +01:00
Nick Wellnhofer
9aba613b14 fuzz: Add new XInclude test directory to corpus 2022-10-31 17:09:54 +01:00
Nick Wellnhofer
b456e3bb42 xinclude: Always allow XPtr expressions in external documents 2022-10-31 16:49:36 +01:00
Nick Wellnhofer
f14529baf5 xinclude: Fix more memory leaks in xmlXIncludeLoadDoc 2022-10-30 14:12:55 +01:00
Nick Wellnhofer
eef0a7395c xinclude: Implement "streaming" mode
When using xmlreader, XPointer expressions in XIncludes simply cannot
work. Expressions can reference nodes which weren't parsed yet or which
were already deleted.

After fixing nested XIncludes, we reference includes which were parsed
previously. When streaming, these nodes could have been deleted, leading
to use-after-free errors.

Disallow XPointer expressions and truncate the include table in
streaming mode.
2022-10-30 14:12:55 +01:00
Nick Wellnhofer
7e078cc1fe xinclude: Clean up xmlXIncludeDoProcess
Only scan new includes in the second pass. Always reset the "replace"
flag.

This only matters if xmlXIncludeDoProcess is called multiple times on
the same document which currently only happens when called from
xmlreader.
2022-10-30 14:12:55 +01:00
Nick Wellnhofer
075cee9e9f xinclude: Fix memory leak when fuzzing
This only affects the fuzzing build mode.
2022-10-29 15:42:01 +02:00
Nick Wellnhofer
b59ff58728 xinclude: Fix memory leak in xmlXIncludeLoadDoc
Regressed in a recent commit.
2022-10-28 20:08:02 +02:00
Nick Wellnhofer
66f781cf38 gitlab-ci: Upgrade image to Ubuntu 22.10, reenable MSan
MSan and 64-bit stat was broken on Ubuntu 22.04 (glibc >= 2.33,
LLVM <= 14), see https://github.com/llvm/llvm-project/commit/1f82d0f7
2022-10-25 19:34:38 +02:00
Nick Wellnhofer
80e43d1b76 gitlab-ci: Reenable LeakSanitizer
Let's hope it works on the asan runners.
2022-10-25 19:34:38 +02:00
Nick Wellnhofer
d767c6bea1 gitlab-ci: Fix llvm-symbolizer
Newer versions of llvm-symbolizer require libxml2 themselves. Running
a test program with LD_LIBRARY_PATH set to .libs makes llvm-symbolizer
pick up the tested development version of libxml2 which breaks
completely if the build is instrumented with ASan. Add a wrapper script
that invokes llvm-symbolizer with an empty LD_LIBRARY_PATH.
2022-10-25 19:34:38 +02:00
Nick Wellnhofer
128c0261c6 warnings: Fix -Wstrict-prototypes warning 2022-10-25 19:34:38 +02:00
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