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

6549 Commits

Author SHA1 Message Date
Nick Wellnhofer
7cbf609ae8 reader: Make xmlTextReaderReadString non-recursive
Also report malloc failures.

Fixes #607.
2024-04-22 12:44:12 +02:00
Nick Wellnhofer
f69647811c reader: Rework xmlTextReaderRead{Inner,Outer}Xml
Use an xmlOutputBuffer. Report malloc failures.
2024-04-22 12:44:12 +02:00
Nick Wellnhofer
cdb3103ba8 reader: Report malloc failures 2024-04-22 12:44:12 +02:00
Nick Wellnhofer
d2daf33e33 reader: Fix preservation of attributes
Don't use 'curnode' which might be an attribute or namespace node
which doesn't have an 'extra' member.
2024-04-22 12:44:12 +02:00
Nick Wellnhofer
5aa56e7397 reader: Add tests for content accessors 2024-04-22 12:44:12 +02:00
Niels Dossche
6053f1ff54 Remove redundant size check
The condition size > UINT_MAX - 10 is already checked earlier, so the
check is always false.
2024-04-19 15:33:40 +02:00
Nick Wellnhofer
fbea03f3d0 tree: Remove another redundant check in xmlDOMWrapCloneNode
The node type was already checked earlier.
2024-04-19 15:22:30 +02:00
Niels Dossche
1a865567d4 Remove redundant NULL check on cur
This variable is already NULL checked in the previous if condition.
2024-04-19 15:14:15 +02:00
Niels Dossche
6fadd7980a Remove always-false check old == cur
This case is already checked at the start of the function.
There it returns NULL, which seems more correct.
2024-04-19 15:14:15 +02:00
Niels Dossche
2766520062 Remove redundant NULL check on cur
cur = node, and node cannot be NULL as it is checked at the start of the
function.
2024-04-19 15:12:56 +02:00
Nick Wellnhofer
a0341ac8e9 tree: Don't return empty localname in xmlSplitQName{2,3}
Match the behavior of xmlSplitQName and xmlSplitQName4.
2024-04-18 12:11:13 +02:00
Nick Wellnhofer
f506ec6654 parser: Always decode entities in namespace URIs
Also decode entities in namespace URIs if entity substitution wasn't
requested. This should fix some corner cases when comparing namespace
URIs. The Namespaces in XML 1.0 spec says:

> In a namespace declaration, the URI reference is the normalized value
> of the attribute, so replacement of XML character and entity
> references has already been done before any comparison.

Make the serialization code escape special characters in namespace URIs
like in attribute values. This fixes serialization if entities were
substituted when parsing.

Fixes https://gitlab.gnome.org/GNOME/libxslt/-/issues/106
2024-04-15 12:34:26 +02:00
Nick Wellnhofer
971ce40409 fuzz: Also set fuzzAllocFailed if a real allocation fails
Avoid false positives in real OOM situations.
2024-04-14 19:40:22 +02:00
Nick Wellnhofer
20b0bd9800 fuzz: Account for quadratic runtime in xmlXPathTranslateFunction
Avoid fuzzer timeouts caused by this known issue.
2024-04-09 18:00:13 +02:00
Nick Wellnhofer
fd8a35114f error: Fix direct invocation of SAX error handlers
Revert part of commit c5a8aef2 to make it safe to call the default SAX
error handlers directly. This has been deprecated for a long time but
even xmllint still uses these handlers.

Should fix #713.
2024-04-09 16:54:02 +02:00
Nick Wellnhofer
20fca2bb3d save: Report malloc failure in xmlAttrSerializeTxtContent
Flush buffer before checking for errors.
2024-04-09 16:53:57 +02:00
Nick Wellnhofer
1f18d37798 fuzz: Add a few more comments 2024-04-09 13:04:50 +02:00
Seiya Nakata
5bb84b47b8 relaxng: Fix tree corruption in xmlRelaxNGParseNameClass
Don't create cycles in tree structure. This will lead to an infinite
loop or call stack overflow later.

Closes: https://gitlab.gnome.org/GNOME/libxml2/-/issues/711
2024-04-05 13:45:06 +02:00
Nick Wellnhofer
16ccb61dc1 xinclude: Don't try to fix base of non-elements
This would result in a spurious error.
2024-04-05 13:19:56 +02:00
Nick Wellnhofer
af2bda4e87 SAX2: Also check URI length before resolving
We don't want to exceed the size limit of 1 MB in uri.c. Such errors
can't be distinguished from malloc failures.
2024-04-05 13:09:45 +02:00
Vincent Torri
5732ce56f3 meson: Initial commit 2024-04-04 12:23:39 +02:00
Nick Wellnhofer
650f842dbe string: Don't validate UTF-8 in xmlUTF8Strsub
Most string functions can assume valid UTF-8. In order to detect malloc
failures reliably, xmlUTF8Strsub should only return NULL if the start
index is out of bounds or a memory allocation failed.
2024-04-02 15:34:45 +02:00
Nick Wellnhofer
86c27206f9 save: Handle invalid parent pointers in xhtmlNodeDumpOutput
See #255 and commit 85b1792e.
2024-04-02 15:34:45 +02:00
Nick Wellnhofer
f7f1453772 build: Disable support for compression libraries by default
libxml2 has limited support for reading and writing compressed data
with the help of zlib and liblzma which used to be enabled by default.
This only works for files read from the file system and never worked
with memory buffers. My guess is that this feature is virtually unused.

In light of the recently discovered xz backdoor, it's a good time to
disable these features by default to reduce attack surface and prepare
for eventual removal.

If --with-legacy is passed to the Autotools build, compression will
be enabled by default as before.
2024-04-02 13:25:56 +02:00
Nick Wellnhofer
365976dbe0 xinclude: Don't use xmlHasNsProp
This function can malloc and doesn't report failures.

Another design mistake is that xmlUnsetNsProp requires an xmlNs
struct.
2024-03-30 17:17:21 +01:00
Nick Wellnhofer
fe3cbf897e fuzz: Check node type before xmlDocSetRootElement 2024-03-29 15:29:53 +01:00
Nick Wellnhofer
5c55332591 Revert "tree: Only allow elements in xmlDocSetRootElement"
This reverts commit 4b698dbaec.

lxml assumes that xmlDocSetRootElement works with non-elements.
2024-03-29 15:29:53 +01:00
Nick Wellnhofer
7c5daa3763 tree: Ignore namespace with NULL href in xmlSearchNs
Some users set href to NULL to unset a namespace without deleting it.

Also change the duplicate check in xmlNewNs which must agree with
xmlSearchNs.

Short-lived regression from f960c60d.
2024-03-29 15:28:47 +01:00
Nick Wellnhofer
f43197fca7 tree: Don't coalesce text nodes in xmlAdd{Prev,Next}Sibling
Commit 9e1c72da from 2001 introduced a bug where xmlAddPrevSibling and
xmlAddNextSibling would only try to merge text nodes with one of its
new siblings. Commit 4ccd3eb8 fixed this bug but unfortunately, lxml
and possibly other downstream code depend on text nodes not being
merged.

To avoid breaking downstream code while still having somewhat
consistent API behavior, it's probably best to make these functions
never coalesce text nodes.
2024-03-29 14:21:11 +01:00
Nick Wellnhofer
2cc7f71016 SAX2: Fix xmlSAX2EntityDecl with empty base
Short-lived regression.
2024-03-29 13:44:28 +01:00
Nick Wellnhofer
730de88b16 SAX2: Optimize appending children
xmlSAX2AppendChild can make several assumptions which make appending
nodes more efficient. Also handle line numbers in xmlSAX2AppendChild.
2024-03-29 12:59:20 +01:00
Nick Wellnhofer
2a713a8091 tree: Document behavior if xmlSetTreeDoc fails 2024-03-29 12:57:20 +01:00
Nick Wellnhofer
f1e9c7bdf1 tree: Optimize xmlInsertNode
Relink the node directly without calling xmlUnlinkNodeInternal.
2024-03-29 12:57:20 +01:00
Nick Wellnhofer
ea0ee36546 tree: Align xmlAddChild with other node insertion functions
Make xmlAddChild unlink the child before insertion. Originally, linked
children would most likely cause tree corruption. The first fix
disallowed linked nodes, but there are cases where insertion of such
nodes could succeed.

Don't abort if the node is already a child of parent. In this case,
the node will be moved to the end of the child list.
2024-03-29 12:57:20 +01:00
Nick Wellnhofer
e5cdb23f10 tree: Introduce xmlUnlinkNodeInternal
xmlUnlinkNode also removes references to DTD nodes which shouldn't be
done when moving nodes within a document. Introduce a new function
xmlUnlinkNodeInternal which only unlinks a node from the tree.
Remove references to DTD nodes in xmlNodeSetDoc. Note that moving
element and attribute declarations to another document will still leave
references in the source document.
2024-03-29 12:56:56 +01:00
Nick Wellnhofer
1d50df8768 examples: Don't leave temp files 2024-03-28 12:08:13 +01:00
Nick Wellnhofer
bfb02fbca9 fuzz: Fix xmlSetProp in API fuzzer
Finding the old attribute node is a bit more involved.
2024-03-28 11:30:05 +01:00
Nick Wellnhofer
9bce9dbb19 valid: Report malloc failure in xmlValidateOneElement 2024-03-26 14:30:57 +01:00
Nick Wellnhofer
887ad90a1a fuzz: Restrict input size of API fuzzer 2024-03-26 14:23:51 +01:00
Nick Wellnhofer
6c5248e2a9 fuzz: Restrict number of copies in API fuzzer
Avoid timeouts with large inputs.
2024-03-26 14:21:47 +01:00
Nick Wellnhofer
aa04838eab html: Use binary search in htmlEntityValueLookup 2024-03-26 14:21:11 +01:00
Nick Wellnhofer
23a81841d2 tree: Work on documentation 2024-03-25 20:51:14 +01:00
Nick Wellnhofer
52efb20a18 fuzz: Enable float-divide-by-zero on OSS-Fuzz
This was recently disabled globally:

    https://github.com/google/oss-fuzz/pull/11567
2024-03-24 13:43:25 +01:00
Nick Wellnhofer
1ace0e8529 xinclude: Report malloc failure in xmlXIncludeAddNode 2024-03-24 12:28:22 +01:00
Nick Wellnhofer
ad9a5637f9 tree: Fix uninitialized value in xmlSearchNsSafe
Short-lived regression.
2024-03-22 19:37:12 +01:00
Nick Wellnhofer
00c2f549e4 ci: Support ASan in Docker container
Ubuntu now requires libclang-rt-dev for ASan libraries.
2024-03-22 19:16:47 +01:00
Nick Wellnhofer
0e6e39213a ci: Show config.log if configuration failed 2024-03-22 18:39:57 +01:00
Nick Wellnhofer
c978a5d8d4 ci: Remove Python 2 job, update C89 job
Python 2 isn't supported on newer Ubuntu releases. Newer Python
releases have header files which aren't compatible with C89.
2024-03-22 18:34:12 +01:00
Nick Wellnhofer
3d6a25e530 doc: Update Docker CI instructions 2024-03-22 18:22:20 +01:00
Nick Wellnhofer
e7ff3ca43f ci: Update Docker container to Ubuntu 23.10
This removes Python 2.
2024-03-22 18:09:23 +01:00