1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2026-01-26 21:41:34 +03:00
Commit Graph

7158 Commits

Author SHA1 Message Date
Nick Wellnhofer
0f4d36e055 xmllint: Fix memory leak in error case 2025-01-17 13:13:54 +01:00
Nick Wellnhofer
fbaacfe223 encoding: Clean up UCS-4 encodings
Use "UCS-*" instead of "ISO-10646-UCS-*". While the XML spec recommends
"ISO-10646-UCS-2" and "ISO-10646-UCS-4", GNU iconv doesn't understand
these names.

Ignore UCS4_2143 and UCS4_3412 which were never supported.
2025-01-16 16:09:14 +01:00
Nick Wellnhofer
be579a266e reader: Fix return value of xmlTextReaderReadString again
Make sure to return NULL for node types except elements or text to match
the old behavior.

Note that CDATA sections are still treated like text nodes and will have
their content returned.

Fixes #838.
2025-01-15 15:24:58 +01:00
Nick Wellnhofer
86401cc3d2 xmllint: Make --shell ignore some other options
When the shell should be launched with the --shell option, don't
post-validate, stream or dump the document. Ignore the --repeat option.
2025-01-07 19:10:19 +01:00
Nick Wellnhofer
c0c69cb868 xmllint: Always reuse parser context
Simplifies "repeat" logic.
2025-01-07 18:55:35 +01:00
Nick Wellnhofer
a5be2cc303 xmllint: Support --xpath --debug
Dump compiled expression if --debug was supplied.
2025-01-06 19:14:28 +01:00
Nick Wellnhofer
f22707f42b xmllint: Use xmlXPathOrderDocElems for XPath queries 2025-01-06 19:14:21 +01:00
Nick Wellnhofer
ca81916023 include: Use intptr_t to cast between pointers and ints 2025-01-03 20:59:10 +01:00
Nick Wellnhofer
41c10c0cec io: Don't cast file descriptors to pointers
This doesn't work if open() returns 0 which is rare but can happen. Wrap
the fd in a context struct.

Fixes #835.
2025-01-03 20:15:52 +01:00
Nick Wellnhofer
71c37a565d malloc-fail: Fix memory leak in xmlValidateElementContent 2024-12-30 11:42:40 +01:00
Nick Wellnhofer
ab62fc27e8 gitlab-ci: Add --with-valid to medium config
Building --with-valid --without-regexps enables some rarely tested code.

There's an additional test failure in runxmlconf without regexps.
2024-12-28 11:56:51 +01:00
Nick Wellnhofer
cd220b93d8 valid: Remove duplicate error messages when streaming 2024-12-28 11:55:24 +01:00
Nick Wellnhofer
bd2a16489f valid: Fix build --without-regexps 2024-12-28 11:55:24 +01:00
Nick Wellnhofer
41aed0890a automake: Only build testdso when testing 2024-12-26 21:25:23 +01:00
Nick Wellnhofer
0cf25b3de2 Regenerate docs and testapi.c 2024-12-26 21:06:09 +01:00
Nick Wellnhofer
2e3a91a766 doc: Fix documentation 2024-12-26 21:05:39 +01:00
Nick Wellnhofer
53c131f667 doc: Make apibuild.py work again 2024-12-26 20:29:58 +01:00
Nick Wellnhofer
260954c566 autotools: Set AC_CONFIG_AUX_DIR
This should make sure that autoreconf doesn't mess with parent
directories.

Should fix #833.
2024-12-26 18:17:45 +01:00
Nick Wellnhofer
b3871dd138 io: Fix memory leaks of encoding handler in error cases
xmlOutputBufferCreate* must always free the encoding handler.
2024-12-21 21:58:25 +01:00
Nick Wellnhofer
afeff9c52b xinclude: Allow build without XPath
This disables XPath queries and makes the tests fail, but might be
useful.
2024-12-21 21:58:25 +01:00
Nick Wellnhofer
c134e8b4dc include: Make INPUT_CHUNK macro private 2024-12-21 20:02:34 +01:00
Nick Wellnhofer
84a6c82ff8 include: Make most IS_* macros private
Macros like IS_DIGIT or IS_LETTER severely pollute the C namespace.
2024-12-21 20:01:30 +01:00
Nick Wellnhofer
0d4a17af49 valid: Fix and check return value of nodeVPush 2024-12-21 19:41:44 +01:00
Nick Wellnhofer
3f0bac4820 malloc-fail: Handle more malloc failures in schema code
These issues can only arise after a memory allocation failed.

- WXS_ADD_*: Add NULL check and raise error
- XML_SCHEMA_*: Make macros safe
- xmlSchemaParseUnion: Fix leak, raise error, commit after success to
  avoid memory corruption
- xmlSchemaVAddNodeQName: Restore nbItems after partial success,
  raise error
- xmlSchemaIDCAcquireTargetList: Raise error
- xmlSchemaXPathProcessHistory: Handle errors
- xmlSchemaIDCFillNodeTables: Fix leak
- xmlSchemaCheckCVCIDCKeyRef: Handle errors
- xmlSchemaVPushText: Reset flag to avoid memory corruption
- xmlSchemaNewValidCtxt: Handle errors
- xmlSchemaVDocWalk: Fix leak
- xmlSchemaInitBasicType: Handle error
- xmlSchemaCleanupTypesInternal: Fix null deref
- xmlSchemaWhiteSpaceReplace: Handle error
- xmlSchemaParseUInt: Handle error
- xmlSchemaValAtomicType: Fix leak, handle error
- xmlSchemaDateNormalize: Fix leak
2024-12-21 19:41:16 +01:00
Nick Wellnhofer
df7cb96c50 build: Set C standard with CMake and meson
This should add `/std:c11` to MSVC builds which makes sure that the
__STDC_VERSION__ macro is set.
2024-12-21 19:37:38 +01:00
Nick Wellnhofer
3d4f7f47b9 meson: Set WITH_HTTP for config.cmake 2024-12-21 19:37:38 +01:00
Nick Wellnhofer
a11c28a6fc meson: Add warning options 2024-12-21 19:37:38 +01:00
Nick Wellnhofer
2e18e5dc6d memory: Grow dynamic arrays by 50%
Growing by a factor lower than the golden ratio increases the chances of
reusing memory freed from earlier allocations. Set growth rate to 1.5
which also reduces internal fragmentation.
2024-12-21 19:37:38 +01:00
Nick Wellnhofer
b9feb81632 xpath: Check reallocations for overflow
Factor out node set reallocation.
2024-12-21 19:37:38 +01:00
Nick Wellnhofer
db8cce3d27 schemas: Check reallocations for overflow 2024-12-21 19:37:38 +01:00
Nick Wellnhofer
0d6136da21 regexp: Check reallocations for overflow 2024-12-21 19:37:38 +01:00
Nick Wellnhofer
ae41cf9af5 xinclude: Check reallocations for overflow 2024-12-21 19:37:38 +01:00
Nick Wellnhofer
178b11219c valid: Check reallocations for overflow 2024-12-21 19:37:38 +01:00
Nick Wellnhofer
8b2d9ac45b uri: Check reallocations for overflow 2024-12-21 19:37:38 +01:00
Nick Wellnhofer
2042090b45 tree: Check reallocations for overflow 2024-12-21 19:37:38 +01:00
Nick Wellnhofer
307bc230ab pattern: Allocate arrays lazily 2024-12-21 19:37:38 +01:00
Nick Wellnhofer
7b3d1134c3 pattern: Check reallocations for overflow 2024-12-21 19:37:38 +01:00
Nick Wellnhofer
3f72a579c2 entities: Check reallocations for overflow 2024-12-21 19:37:37 +01:00
Nick Wellnhofer
df0f16fa26 encoding: Check reallocations for overflow 2024-12-21 19:37:37 +01:00
Nick Wellnhofer
1c51f3d3f1 catalog: Check reallocations for overflow 2024-12-21 19:37:37 +01:00
Nick Wellnhofer
509d498127 c14n: Check reallocations for overflow 2024-12-21 19:37:37 +01:00
Nick Wellnhofer
58e2e72481 reader: Check reallocations for overflow 2024-12-21 19:37:37 +01:00
Nick Wellnhofer
0447275ef8 html: Check reallocations for overflow 2024-12-21 19:37:37 +01:00
Nick Wellnhofer
8231c03663 parser: Check reallocations for overflow 2024-12-21 19:37:37 +01:00
Nick Wellnhofer
5320a4aa38 memory: Implement xmlGrowCapacity to safely grow arrays
xmlGrowCapacity makes sure that dynamic arrays don't grow beyond an
explicit maximum size. size_t considerations are also taken into account.
A macro XML_MAX_ITEMS is provided as default maximum with value
1 billion.

When fuzzing, the initial size is set to 1 to cause more reallocations.
This can require adjustments if callers really need larger arrays.
2024-12-21 19:37:37 +01:00
Nick Wellnhofer
afbc0a0405 xpath: Make contextSize and proximityPosition default to 1
In the general case of processing a single node, these values should be
set to 1.
2024-12-21 16:57:39 +01:00
Nick Wellnhofer
e014cc570f xpath: Remove non-standard xf:escape-uri function
This undocumented function used an outdated namespace URI and is
unlikely to be used these days.
2024-12-21 16:55:35 +01:00
Nick Wellnhofer
bf5fcf6e64 xpath: Use separate static hash table for standard functions
This avoids registering standard functions when creating an XPath
context.

Lookup of extension functions is a bit slower now, but ultimately, all
function lookups should be moved to the compilation phase.
2024-12-21 16:55:35 +01:00
Nick Wellnhofer
0dd910e82b save: Fix handling of catastrophic errors
Don't overwrite catastrophic errors xmlSaveErr.

Overwrite non-catastrophic errors in xmlOutputBufferClose.
2024-12-19 02:30:36 +01:00
Nick Wellnhofer
72f84dd739 fuzz: Inject IO failures into serialization code 2024-12-17 22:21:34 +01:00