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

6697 Commits

Author SHA1 Message Date
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
Nick Wellnhofer
802ad903f8 valid: Don't report errors with null context 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
f797cdabf5 valid: Remove id before updating attribute type 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
a3e11e3de1 valid: Fix id handling in xmlValidateDtd
Free id table before and after validation.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
c4e0db6a9e valid: Reset attribute in xmlFreeID 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
bbbd7f7786 valid: Rework checks in xmlValidateOneElement
Don't check element for extra members and missing content.

Consolidate checks for unexpected elements.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
b23175d1d8 valid: Check element type in xmlIsID
Also rearrange code for readability.
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
0ddd63dbab valid: Change error code to XML_ERR_ARGUMENT 2024-03-15 19:47:07 +01:00
Nick Wellnhofer
b043d9590e tree: Check return value of xmlNodeAddContent 2024-03-15 19:47:07 +01:00
Nick Wellnhofer
18ebdacf80 tree: Fix error return in xmlGetPropNodeValueInternal 2024-03-15 19:47:07 +01:00
Nick Wellnhofer
e4e9096164 tree: Prefer xmlGetPropNodeInternal over xmlHasNsProp
xmlHasNsProp can cause unreported malloc failures when looking up
default attributes. Switch to xmlGetPropNodeInternal when moving
attributes. We don't care about default attributes in this case.
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
7d9ffd40e1 tree: Report malloc failure in xmlAddNextSibling 2024-03-15 19:47:07 +01:00
Nick Wellnhofer
bc7ab5a2e6 tree: Rewrite xmlSetTreeDoc
Report malloc failures.

Fix when called directly on attribute node.

Clear 'content' and 'last' and look up new entity for entity reference
nodes.
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
2ba690a78f tree: Remove more unused node types 2024-03-15 19:47:07 +01:00
Nick Wellnhofer
fc9a2ca0f3 tree: Report more malloc failures 2024-03-15 19:47:07 +01:00
Nick Wellnhofer
536aa2cd3e tree: Fix adding ids in xmlNewPropInternal
Don't try to add ids to NULL document.

Report malloc failure from xmlIsID.
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
d0d6174e81 valid: Rework xmlAddID 2024-03-15 19:47:07 +01:00
Nick Wellnhofer
d57c57ed2f tree: Improve argument check in xmlTextConcat 2024-03-15 19:47:07 +01:00
Nick Wellnhofer
16c2955733 tree: Remove unused node types 2024-03-15 19:47:07 +01:00
Nick Wellnhofer
f960c60d18 tree: Make namespace comparison more consistent
The API allows NULL namespace URIs, so we should match them
consistently. Simply use xmlStrEqual which already takes NULL strings
into account.
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
d1cc6f7df2 tree: Don't allow NULL name in xmlSetNsProp 2024-03-15 19:47:07 +01:00
Nick Wellnhofer
2840e33c5e tree: Allocate XML namespace statically 2024-03-15 19:47:07 +01:00
Nick Wellnhofer
696faeb474 tree: Rework xmlNodeListGetString
Use string buffer to avoid quadratic complexity.

Handle entities with xmlBufGetNodeContent.

Report malloc failures.
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
4196454818 tree: Rework xmlTextMerge
Return NULL on error. Check for malloc failure. Check that nodes are
distinct.
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
a3713f78e3 tree: Rework xmlNodeSetName
Disallow xmlNodeSetName on DTD nodes. DTD nodes don't store the name in
a dictionary. Calling xmlNodeSetName with a DTD node could result in an
invalid free.

This function doesn't report errors but we can make sure that name
isn't set to NULL.
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
77c713501b tree: Simplify xmlAddChild with text parent 2024-03-15 19:47:07 +01:00
Nick Wellnhofer
7e46242568 tree: Don't allow misuse of xmlAddChild
xmlAddChild assumes that the child is unlinked. If the child is already
linked, return an error instead of corrupting the tree.
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
2c214a508d tree: Fix xmlAddPropSibling with duplicate attributes
Look up existing attribute before unlinking new attribute. This makes
it easier for the fuzzer to detect which attribute will de deleted if
there are multiple attributes with the same name.
2024-03-15 19:47:06 +01:00
Nick Wellnhofer
2e7650830d tree: Fix indentation in xmlAddPropSibling 2024-03-15 19:47:06 +01:00
Nick Wellnhofer
16c0374a7d tree: Fix xmlAddSibling with last sibling
If the node to be added was already at the correct position, the tree
could be corrupted.
2024-03-15 19:47:06 +01:00
Nick Wellnhofer
74ca2f5952 tree: Move type check in xmlAddChild
Avoid aborting halfway after changing parent pointer if node types
don't match when adding attributes.
2024-03-15 19:47:06 +01:00
Nick Wellnhofer
29db988165 tree: Fix xmlDocSetRootElement with multiple top-level elements
Fix xmlDocSetRootElement when setting the original root if multiple
top-level elements are present.
2024-03-15 19:47:06 +01:00
Nick Wellnhofer
4b698dbaec tree: Only allow elements in xmlDocSetRootElement 2024-03-15 19:47:06 +01:00
Nick Wellnhofer
d5f5060246 tree: Disallow setting content of entity reference nodes
The content of entity reference nodes points to the entity declaration
and isn't freed. Changing the content would result in a memory leak.
2024-03-15 19:47:06 +01:00
Nick Wellnhofer
77f2012ca7 tree: Rework xmlReconciliateNs 2024-03-15 19:47:06 +01:00
Nick Wellnhofer
af66a6b59b tree: Unlink DTD in xmlStaticCopyNodeList
Avoid tree corruption when copying within a document.
2024-03-15 19:47:06 +01:00
Nick Wellnhofer
bb22cfb900 tree: Unlink DTD in xmlFreeNodeList
Avoid dangling next/prev pointers.
2024-03-15 19:47:06 +01:00
Nick Wellnhofer
186562a182 parser: Fix detection of duplicate attributes in XML namespace
Fixes a regression from commit e0dd330b, resulting in duplicate
attributes in the predefined XML namespace not being detected or
extraneous default attributes being passed.

Fixes #704.
2024-03-12 20:02:52 +01:00
Nick Wellnhofer
ce8f3d2c1d fuzz: Improve README 2024-03-10 15:04:00 +01:00
Nick Wellnhofer
723b4de040 catalog: Fetch XML catalog before dumping
Catalog entries seem to be loaded lazily.

Should fix #699.
2024-03-03 22:29:05 +01:00
Benjamin Gilbert
653ef99902 schemas: fix spurious warning about truncated snprintf output
Fix warning:

    xmlschemas.c: In function 'xmlSchemaVAttributesComplex':
    xmlschemas.c:25506:63: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
    xmlschemas.c:25506:29: note: 'snprintf' output between 3 and 13 bytes into a destination of size 12

On my system (GCC 13.2.1 x86_64) the warning only appears with -O0.
counter can't exceed 1000, so there's no real bug.
2024-03-02 17:03:28 +09:00