valid.c


Log

Author Commit Date CI Message
Nick Wellnhofer 347c2b2e 2025-06-02T23:26:19 valid: Deprecate a few functions and `xmllint --insert`
Nick Wellnhofer ac6ae391 2025-06-02T14:33:15 valid: Readd more argument checks in xmlAddElementDecl Fix crashes with API fuzzer.
Nick Wellnhofer 7bd8d1d9 2025-05-28T15:53:38 doc: Prefix autolinks with '#' Use `#func` instead of `func()` to ignore parameters and make all autolinks work.
Nick Wellnhofer 77c583e0 2025-05-27T12:19:25 valid: Readd argument check in xmlAddElementDecl Fix crashes with API fuzzer.
Nick Wellnhofer fc1cabc8 2025-05-25T14:03:50 valid: Also raise duplicate ID error without validation support Whether an error is raised should not depend on config options.
Nick Wellnhofer dd1961e0 2025-05-20T16:37:18 valid: Skip more validity checks if not validating
Nick Wellnhofer 6c2bd975 2025-05-20T15:51:18 valid: Don't validate unused default attributes See erratum E9 of XML 1.0 Second Edition. See #120.
Nick Wellnhofer 6f8ac953 2025-05-20T23:17:55 valid: Don't use element namespace for attributes This makes no sense. Unprefixed attributes never have a namespace.
Nick Wellnhofer 5ec83f77 2025-05-20T03:21:27 valid: Remove duplicate #FIXED check for namespaces Unlike the comment indicates, this is already checked.
Nick Wellnhofer 7c10fff2 2025-05-20T22:48:25 valid: Don't validate twice in xmlAddAttributeDecl This should only be done in xmlValidateAttributeDecl.
Nick Wellnhofer 2a60ca06 2025-05-20T16:50:32 valid: Don't check enum values Rely on the parser to pass valid arguments.
Nick Wellnhofer 7008740a 2025-05-18T01:52:38 parser: Consolidate scanning of XML Names Use new productions by default. Fixes #194. Fixes #364. See #707.
Nick Wellnhofer c5b45fbc 2025-05-16T16:54:09 doc: Misc fixes
Nick Wellnhofer adfbeb7e 2025-05-14T04:58:21 doc: Stop using *Ptr typedefs in documentation
Nick Wellnhofer a40f36e7 2025-05-14T04:04:28 include: Stop using *Ptr typedefs in public headers
Nick Wellnhofer 9bbffec5 2025-05-06T17:42:46 doc: Move brief to top, params to bottom of doc comments
Nick Wellnhofer 81ac2e27 2025-05-04T18:41:44 doc: Misc fixes to valid docs
Nick Wellnhofer 2c150e62 2025-05-02T20:18:34 doc: Formatting fixes
Nick Wellnhofer cb1635a6 2025-05-02T19:05:25 doc: Use @since command
Nick Wellnhofer e78e05c9 2025-05-02T17:32:51 doc: Fix autolinks to functions Unfortunately, autolinks in .c files aren't converted by Doxygen for some reason.
Nick Wellnhofer f7c41287 2025-05-02T15:57:17 doc: Remove more comment block headers
Nick Wellnhofer e525564f 2025-05-01T19:20:06 doc: Remove empty lines at start of block These lines were left over after automatic conversion.
Nick Wellnhofer e549622b 2025-04-28T15:11:24 doc: Convert documentation to Doxygen Automated conversion based on a few regexes.
Nick Wellnhofer 69879da8 2025-04-28T14:04:30 doc: Remove email addresses from documentation Also remove authorship information from generated files, hash.c and globals.c which were rewritten.
Nick Wellnhofer 61890e39 2025-04-27T21:50:15 doc: Prepare for conversion to Doxygen Fix many params in internal functions (not really necessary but Doxygen warns about that in XML mode). Fix formatting in a few corner cases that automatic conversion can't handle. Rearrange some DOC_DISABLE blocks.
Nick Wellnhofer 6896f478 2025-04-18T17:22:36 Revert "valid: Remove duplicate error messages when streaming" This reverts commit cd220b93d8ffffd2fb7cac0ec792bebb7e082521. This commit broke the xmstarlet tests.
Nick Wellnhofer 63dfcca6 2024-12-16T01:34:29 fuzz: Reduce initial array size
Nick Wellnhofer 8c8753ad 2025-02-11T17:30:40 [CVE-2025-24928] Fix stack-buffer-overflow in xmlSnprintfElements Fixes #847.
Zak Ridouh b466e70a 2025-02-05T14:11:04 Fix early return in vstateVPush in valid.c While looking over the code in the fallback method for `vstateVPush` in valid.c when `LIBXML_REGEXP_ENABLED` is not defined, I noticed that there is an ungated `return(-1)` after attempting to allocate memory. I believe this should be inside a check, for if the malloc fails.
Nick Wellnhofer 71c37a56 2024-12-30T11:41:44 malloc-fail: Fix memory leak in xmlValidateElementContent
Nick Wellnhofer cd220b93 2024-12-27T14:55:43 valid: Remove duplicate error messages when streaming
Nick Wellnhofer bd2a1648 2024-12-27T13:44:10 valid: Fix build --without-regexps
Nick Wellnhofer 2e3a91a7 2024-12-26T21:05:18 doc: Fix documentation
Nick Wellnhofer 0d4a17af 2024-12-18T12:02:36 valid: Fix and check return value of nodeVPush
Nick Wellnhofer 178b1121 2024-12-15T22:44:39 valid: Check reallocations for overflow
Nick Wellnhofer 5204c872 2024-11-26T10:40:16 valid: Reset context before validating Reset last error and "stopped" flag. Otherwise new errors could be ignored.
Nick Wellnhofer 4d1f35b0 2024-11-17T19:45:16 valid: Deprecate more internal functions
Nick Wellnhofer 5a51f085 2024-11-17T13:50:15 valid: Implement xmlCtxtValidateDocument This allows to use the error handler or resource loader of a parser context.
Nick Wellnhofer 1e1731a4 2024-11-17T13:20:06 valid: Add NULL check in xmlCtxtValidateDtd
Nick Wellnhofer 7f8c436c 2024-11-15T16:30:52 parser: Implement xmlCtxtParseDtd and xmlCtxtValidateDtd This allows to use the context's error handler, options and other settings. Fixes #808.
Nick Wellnhofer 0c56eb82 2024-08-12T21:38:50 tree: Restore return value of xmlNodeListGetString with NULL list When passing a NULL list to xmlNodeListGetString or xmlNodeListGetRawString, return NULL instead of "" to match the old behavior. Fixes #783.
Nick Wellnhofer 6be79014 2024-07-15T14:18:26 Remove unused code
Nick Wellnhofer 842a0448 2024-07-03T11:46:06 valid: Restore ID lookup Revert a change from d025cfbb and don't overwrite ID table entries, so that the first attribute will be returned if there are duplicate IDs. This requires two other changes: - Attributes in entity content are never added to the ID table. This seems reasonable. - Remove the optimization to skip ID lookup when copying and the target document has an empty ID table. This also seems more correct since the document could have ID declarations nevertheless or we could be copying xml:ids into the document for the first time. Fixes #757.
Rosen Penev 2def7b4b 2024-06-18T13:55:34 clang-tidy: move assignments out of if Found with bugprone-assignment-in-if-condition Signed-off-by: Rosen Penev <rosenp@gmail.com>
Rosen Penev 217e9b7a 2024-06-08T12:27:45 clang-tidy: don't return in void functions Found with readability-redundant-control-flow Signed-off-by: Rosen Penev <rosenp@gmail.com>
Nick Wellnhofer 1b640358 2024-06-16T00:39:39 schemas: Stop using xmlValidateNotationUse Simplify symbol availability logic.
Nick Wellnhofer b0fc67aa 2024-06-15T22:53:55 build: Remove --with-tree configuration option This option would allow for a smaller, but mostly useless minimal build. But it complicates the symbol availability logic in an insane way and requires specialized tools like our custom C parser in doc/apibuild.py. See #717.
Nick Wellnhofer 11cd18d8 2024-05-31T13:31:09 valid: Check return value of xmlValidBuildAContentModel Fixes return code in case of malloc failure.
Nick Wellnhofer e75e878e 2024-05-20T13:58:22 doc: Update and fix documentation
Nick Wellnhofer 0651ad66 2024-05-05T20:20:22 valid: Report malloc failure after xmlRegExecPushString
Nick Wellnhofer 9bce9dbb 2024-03-26T14:30:57 valid: Report malloc failure in xmlValidateOneElement
Nick Wellnhofer 577e2516 2024-03-19T17:06:07 valid: Check for NULL node->name in xmlSnprintfElements Unfortunately, we can have NULL element names if xmlSetTreeDoc fails.
Nick Wellnhofer dc2a03d4 2024-03-16T14:50:56 valid: Deprecate internal validation functions
Nick Wellnhofer 291a9d0f 2024-03-08T18:45:24 valid: Set document on dummmy element declaration
Nick Wellnhofer 9033a270 2024-03-05T16:45:44 malloc-fail: Stop using xmlSplitQName2 This function doesn't report malloc failures.
Nick Wellnhofer b38f8eae 2024-03-05T14:55:15 malloc-fail: Report in xmlAddAttributeDecl
Nick Wellnhofer 3061b56a 2024-03-15T02:23:08 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.
Nick Wellnhofer af3d80b9 2024-03-14T20:49:39 valid: Check for elem->name in xmlIsID elem->name can be NULL is xmlNodeSetDoc failed.
Nick Wellnhofer 1233805d 2024-03-06T15:49:20 valid: Fix some return codes after errors
Nick Wellnhofer 04c691f7 2024-03-05T19:59:42 valid: Eliminate xmlCtxtGetDtdElementDesc Improves malloca failure reporting without parser context.
Nick Wellnhofer ab345338 2024-03-05T19:58:17 valid: Report malloc failure in legacy DTD serialization
Nick Wellnhofer 264b283c 2024-03-05T14:55:42 valid: Fix hash removal in xmlRemoveRef Don't create a NULL entry.
Nick Wellnhofer 802ad903 2024-03-05T14:54:16 valid: Don't report errors with null context
Nick Wellnhofer f797cdab 2024-03-02T18:59:16 valid: Remove id before updating attribute type
Nick Wellnhofer a3e11e3d 2024-03-01T15:55:35 valid: Fix id handling in xmlValidateDtd Free id table before and after validation.
Nick Wellnhofer c4e0db6a 2024-03-02T16:02:39 valid: Reset attribute in xmlFreeID
Nick Wellnhofer bbbd7f77 2024-03-01T14:27:08 valid: Rework checks in xmlValidateOneElement Don't check element for extra members and missing content. Consolidate checks for unexpected elements.
Nick Wellnhofer b23175d1 2024-02-29T19:57:28 valid: Check element type in xmlIsID Also rearrange code for readability.
Nick Wellnhofer 0ddd63db 2024-02-29T16:40:26 valid: Change error code to XML_ERR_ARGUMENT
Nick Wellnhofer d0d6174e 2024-02-29T19:38:29 valid: Rework xmlAddID
Nick Wellnhofer 9835ec2b 2024-02-13T10:58:19 valid: Fix xmlAddIDSafe in "streaming" mode Make sure that IDs and attributes never reference each other in streaming (XML reader) mode, even when attributes are copied from an entity. Also update lineno. Fixes a short-lived use-after-free.
Nick Wellnhofer 2807df9a 2024-02-06T12:07:19 valid: Fix another use-after-free in xmlAddIDSafe Short-lived regression.
Nick Wellnhofer 70da4c08 2024-02-04T13:30:32 valid: Fix use-after-free in xmlAddIDSafe Short-lived regression.
Nick Wellnhofer cf875194 2024-02-01T19:26:42 valid: Deprecate old DTD serialization API
Nick Wellnhofer fbe10a46 2024-02-01T19:01:57 save: Move DTD serialization code to xmlsave.c
Nick Wellnhofer 661ef936 2024-01-02T18:50:59 valid: Fix some error codes
Nick Wellnhofer d025cfbb 2023-12-27T03:53:24 parser: Always copy content from entity to target. Make sure that references from IDs are updated. Note that if there are IDs with the same value in a document, the last one will now be returned. IDs should be unique, but maybe this should be addressed.
Nick Wellnhofer 13043691 2023-12-20T00:33:34 parser: Rename xmlErrParser to xmlCtxtErr
Nick Wellnhofer 54c70ed5 2023-12-18T19:31:29 parser: Improve error handling Introduce xmlCtxtSetErrorHandler allowing to set a structured error for a parser context. There already was the "serror" SAX handler but this always receives the parser context as argument. Start to use xmlRaiseMemoryError. Remove useless arguments from memory error functions. Rename xmlErrMemory to xmlCtxtErrMemory. Remove a few calls to xmlGenericError. Remove support for runtime entity debugging.
Nick Wellnhofer 355fbe3a 2023-12-16T15:02:43 valid: Fix handling of enumerations Make xmlFreeEnumeration, xmlCopyEnumeration and xmlDumpEnumeration non-recursive. Report malloc failure in xmlCopyEnumeration.
Nick Wellnhofer 61b4c42f 2023-12-10T18:27:42 valid: Report malloc failures Fix many places where malloc failures aren't reported.
Nick Wellnhofer e34a49b7 2023-12-10T16:29:31 valid: Improve addition and deletion of IDs Introduce a new API function xmlAddIDSafe that returns a separate error code if a memory allocation fails. Store a pointer to the ID struct in xmlAttr so attributes can be freed without allocating memory. It's impossible to report malloc failures in deallocation code.
Nick Wellnhofer 8c084ebd 2023-09-21T22:57:33 doc: Make apibuild.py happy
Nick Wellnhofer 699299ca 2023-09-20T18:54:39 globals: Stop including globals.h
Nick Wellnhofer 4e1c13eb 2023-09-18T14:45:10 debug: Remove debugging code This is barely useful these days and only clutters the code base.
Nick Wellnhofer 58de9d31 2023-08-03T12:00:55 valid: Fix c1->parent pointer in xmlCopyDocElementContent Fixes #572.
David Kilzer cb1b8b85 2023-04-10T13:06:18 xmlValidatePopElement() can return invalid value (-1) Covered by: test/VC/ElementValid5 This only affects XML Reader API with LIBXML_REGEXP_ENABLED and LIBXML_VALID_ENABLED turned on. * result/VC/ElementValid5.rdr: - Update result to add missing error message. * python/tests/reader2.py: * result/VC/ElementValid6.rdr: * result/VC/ElementValid7.rdr: * result/valid/781333.xml.err.rdr: - Update result to fix grammar issue. * valid.c: (xmlValidatePopElement): - Check return value of xmlRegExecPushString() to handle -1, and assign 'ret = 0;' to return 0 from xmlValidatePopElement(). This change affects xmlTextReaderValidatePop() from xmlreader.c. - Fix grammar of error message by changing 'child' to 'children'.
Nick Wellnhofer 08f9d319 2023-03-16T17:01:05 valid: Make xmlValidateElement non-recursive Fixes call stack overflows when validating deeply nested documents. Found by OSS-Fuzz.
Nick Wellnhofer a57a7549 2023-03-12T16:06:19 valid: Allow xmlFreeValidCtxt(NULL)
Nick Wellnhofer 9fa1b228 2023-02-14T16:43:35 malloc-fail: Fix memory leak in xmlGetDtdElementDesc2 Found with libFuzzer, see #344.
Nick Wellnhofer dd3569ea 2022-12-08T02:43:17 Remove XMLDECL macro from .c files
Alex Richardson 4b959ee1 2022-12-01T13:23:09 Remove hacky heuristic from b2dc5675e94aa6b5557ba63f7d66b0f08dd17e4d Checking whether the context is close to the parent context by hardcoding 250 is not portable (I noticed tests were failing on Morello since the value is 288 there due to pointers being 128 bits). Instead we should ensure that the XML_VCTXT_USE_PCTXT flag is not set in cases where the user data is not actually a parser context (or ideally add a separate field but that would be an ABI break. From what I can see in the source, the XML_VCTXT_USE_PCTXT is only set if the userData field points to a valid context, and if this is not the case the flag should be cleared when changing userData rather than relying on the offset between the two. Looking at the history, I think d7cb33cf44aa688f24215c9cd398c1a26f0d25ff fixed most of the need for this workaround, but it looks like there are a few more locations that need updating; This commit changes two more places to set/clear/copy the XML_VCTXT_USE_PCTXT flag, so this heuristic should not be needed anymore. I've also drop two = NULL assignment in xmllint since this is not needed after a call to memset(). There was also an uninitialized vctxt.flags (and other fields) in `xmlShellValidate()`, which I've fixed by adding a memset() call.
Nick Wellnhofer c7149792 2022-09-01T23:15:35 Fix --with-valid --without-regexps build This build config resulted in segfaults in 'runtest' because a special xmlElementContentPtr showed up in a few places. I'm not sure if this is the right fix. An error message was changed to conform to the --with-regexps build. There are still a few missing validity errors, so the tests don't pass.
Nick Wellnhofer ad338ca7 2022-09-01T01:18:30 Remove explicit integer casts Remove explicit integer casts as final operation - in assignments - when passing arguments - when returning values Remove casts - to the same type - from certain range-bound values The main motivation is that these explicit casts don't change the result of operations and only render UBSan's implicit-conversion checks useless. Removing these casts allows UBSan to detect cases where truncation or sign-changes occur unexpectedly. Document some explicit casts as truncating and add a few missing ones.
Nick Wellnhofer 0f568c0b 2022-08-26T01:22:33 Consolidate private header files Private functions were previously declared - in header files in the root directory - in public headers guarded with IN_LIBXML - in libxml.h - redundantly in source files that used them. Consolidate all private header files in include/private.
David Kilzer b7e8e4c7 2022-04-06T18:05:20 Fix leak of xmlElementContent * valid.c: (xmlCopyDocElementContent): - Set `tmp->parent` properly to fix a leak that occurs in xmlFreeDocElementContent(). - Appears to be a regresion from cee2b3a5f1. Found by OSS-Fuzz Issue 44509.
Nick Wellnhofer 4a8c71eb 2022-03-04T03:35:57 Remove DOCBparser This code has been broken and deprecated since version 2.6.0, released in 2003. Because of a bug in commit 961b535c, DOCBparser.c was never compiled since 2012. I couldn't find a Debian package using any of its symbols, so it seems safe to remove this module.
Nick Wellnhofer 776d15d3 2022-03-02T00:29:17 Don't check for standard C89 headers Don't check for - ctype.h - errno.h - float.h - limits.h - math.h - signal.h - stdarg.h - stdlib.h - string.h - time.h Stop including non-standard headers - malloc.h - strings.h
Nick Wellnhofer d05317ce 2022-02-22T11:51:08 Fix --without-valid build Regressed in commit 652dd12a.
Nick Wellnhofer 004fe9de 2022-02-20T19:02:31 Deprecate IDREF-related functions in valid.h These functions are only needed internally for validation. xmlGetRefs is inherently unsafe because the ref table isn't updated if attributes are removed (unlike the ids table). None of the Ubuntu 20.04 packages depending on libxml2 use any of these functions (except xmlFreeRefTable in libxslt), so it seems perfectly safe to deprecate them. Remove xmlIsRef and xmlRemoveRef from the Python bindings.