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

6737 Commits

Author SHA1 Message Date
Nick Wellnhofer
3bdd0d7b30 xinclude: Set errNo in xmlXIncludeErrMemory 2024-03-18 14:13:15 +01:00
Nick Wellnhofer
6a49bb777c tree: Introduce xmlSearchNsSafe
After the failed experiment with a static XML namespace, introduce
versions of xmlSearchNs that report malloc failures.

Optimize the no-document case by only adding the XML namespace
declaration if it wasn't found in an ancestor.
2024-03-17 21:07:46 +01:00
Nick Wellnhofer
047ea3ecb3 Revert "tree: Allocate XML namespace statically"
This reverts commit 2840e33c5e4b51589a0b96e8102638eeaea6df72.
2024-03-17 21:04:40 +01:00
Nick Wellnhofer
fb1e63025b save: Check for NULL node->name in xhtmlIsEmpty 2024-03-17 19:42:59 +01:00
Nick Wellnhofer
869f72442a schemas: Fix ADD_ANNOTATION
Fix adding multiple annotations.
2024-03-17 16:14:04 +01:00
Nick Wellnhofer
1b4bf22c14 xmlreader: Fix memory leak in xmlTextReaderFreeProp
Short-lived regression.
2024-03-17 16:14:04 +01:00
Nick Wellnhofer
dc2a03d482 valid: Deprecate internal validation functions 2024-03-16 15:20:08 +01:00
Nick Wellnhofer
c0edd792ba fuzz: Move fuzzer options to environment variable 2024-03-16 15:20:08 +01:00
Nick Wellnhofer
55175f7537 fuzz: Add OSS-Fuzz build.sh
Move build.sh to our repo to facilitate changes.
2024-03-15 22:07:23 +01:00
Nick Wellnhofer
f14f089fe3 fuzz: Add some comments in api.c 2024-03-15 22:07:23 +01:00
Nick Wellnhofer
ee0c1f87c0 fuzz: New tree API fuzzer 2024-03-15 19:54:27 +01:00
Nick Wellnhofer
2469d5d065 tree: Tighten source doc check in xmlDOMWrapAdoptNode
sourceDoc must match even if node->doc is NULL.
2024-03-15 19:54:27 +01:00
Nick Wellnhofer
37556eb32a tree: Check destParent->doc in xmlDOMWrapCloneNode
The document must match destDoc to avoid tree corruption.
2024-03-15 19:54:27 +01:00
Nick Wellnhofer
7c48c01b1c tree: Switch to xmlNodeSetDoc in xmlDOMWrapAdoptNode
Report malloc failures.

Also fixes an issue where xmlDOMWrapAdoptAttr would descend into entity
references.
2024-03-15 19:54:27 +01:00
Nick Wellnhofer
be2c26fb67 tree: Fix tree iteration in xmlDOMWrapRemoveNode
We didn't descend into elements having attributes.
2024-03-15 19:54:27 +01:00
Nick Wellnhofer
4a90ce089c tree: Don't abort early if malloc fails in DOM functions
If malloc fails halfway through updating a subtree, we must process the
rest of the tree to avoid tree corruption.
2024-03-15 19:54:27 +01:00
Nick Wellnhofer
ad019ba102 tree: Fix reallocation in xmlDOMWrapNSNormAddNsMapItem2 2024-03-15 19:54:27 +01:00
Nick Wellnhofer
e321eba0c7 tree: Set parent->last early in xmlDOMWrapCloneNode
Avoids a corrupted tree in error case.
2024-03-15 19:54:27 +01:00
Nick Wellnhofer
84e6dc9e5b tree: Declare namespace on clone in xmlDOMWrapCloneNode
The new namespace must be declared on the cloned node, not the source
node.
2024-03-15 19:54:27 +01:00
Nick Wellnhofer
09905670f4 tree: Don't free linked DOM namespaces in error case 2024-03-15 19:54:27 +01:00
Nick Wellnhofer
27f07f1002 tree: Report malloc failure in xmlDOMWrapCloneNode
Also don't store text content in dictionaries.
2024-03-15 19:54:26 +01:00
Nick Wellnhofer
8d04f0eea0 tree: Refactor text node updates 2024-03-15 19:54:26 +01:00
Nick Wellnhofer
4ccd3eb80f tree: Refactor node insertion
Also fixes a text coalescing bug.
2024-03-15 19:54:26 +01:00
Nick Wellnhofer
9f049afa6d tree: Refactor element creation and parsing of attribute values
Replace xmlStringGetNodeList and xmlStringLenGetNodeList with
xmlNodeParseContentInternal which also updates an optional parent
node.

Don't look up entities a second time via xmlNewReference.
2024-03-15 19:54:26 +01:00
Nick Wellnhofer
9991fae4f4 tree: Simplify xmlNodeGetContent, xmlBufGetNodeContent
Factor out xmlBufGetEntityRefContent and xmlBufGetChildContent.

Also allow entity declarations.

Optimize single text children.

Ignore missing or recursive entities silently.

Prefer xmlNodeGetContent over xmlNodeListGetString.

Check for entity cycles in xmlBufGetNodeContent.

Use children pointer of entity reference nodes if available to look up
entities.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
05adfbf880 buf: Don't use default buffer size for small strings
Detaching strings from a buffer with a default size of 4096 can waste
a lot of memory.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
291a9d0f81 valid: Set document on dummmy element declaration 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
e3342f731c tree: Work on documentation 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
aef1ff4372 string: Fix xmlStrncatNew(NULL, "")
This should return "" not NULL.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
9033a27068 malloc-fail: Stop using xmlSplitQName2
This function doesn't report malloc failures.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
b38f8eae07 malloc-fail: Report in xmlAddAttributeDecl 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
8677f54703 malloc-fail: Fix erroneous report in xmlNodeGetBaseSafe 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
9b3750c660 malloc-fail: Avoid use-after-free in xmlAddChild
Returning NULL doesn't signal that the node was freed.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
702f2e463c malloc-fail: Fix memory leak in xmlNewNodeEatName 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
10c202f9dc malloc-fail: Check for NULL pointer in xmlSaveNotation* 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
9c2d451c02 malloc-fail: Fix use-after-free in xmlBufBackToBuffer 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
edbf1eb63b entities: Don't allow null name in xmlNewEntity 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
50816b8d1a entities: Check for illegal entity types in xmlAddEntity 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
c1fe9e72ef io: Report more malloc failures when writing to output buffer 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
10c4ed1f2d html: Fix quadratic behavior in htmlNodeDump
Use an efficient buffer allocation scheme.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
b1e75a9191 save: Report malloc failure in xmlAttrSerializeTxtContent 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
3494aa4fd5 save: Cast return code of xmlBufNodeDump
Avoid implicit sign change.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
1d392fabb9 save: Check for output buffer errors
Report more error conditions.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
d2f7ca5305 save: Add range check for level in xmlNodeDump 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
3061b56a1e valid: Check for NULL text content in xmlValidateOneElement
Shouldn't occur in parsed documents but you can create text nodes with
NULL content through the API.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
af3d80b9a0 valid: Check for elem->name in xmlIsID
elem->name can be NULL is xmlNodeSetDoc failed.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
1233805dcb valid: Fix some return codes after errors 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
04c691f7ea valid: Eliminate xmlCtxtGetDtdElementDesc
Improves malloca failure reporting without parser context.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
ab345338a4 valid: Report malloc failure in legacy DTD serialization 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
264b283c27 valid: Fix hash removal in xmlRemoveRef
Don't create a NULL entry.
2024-03-15 19:47:08 +01:00