Log

Author Commit Date CI Message
Nick Wellnhofer 253f260b 2023-10-18T20:06:35 threads: Fix --with-thread-alloc Fixes #606.
Nick Wellnhofer 4f132bcd 2023-10-14T22:49:29 fuzz: Raise rss_limit_mb
Nick Wellnhofer e019d97f 2023-10-14T22:47:20 fuzz: Test XML_PARSE_XINCLUDE | XML_PARSE_VALID
Nick Wellnhofer c13a0191 2023-10-14T22:48:12 fuzz: Test xmlTextReaderRead after EOF or failure
Nick Wellnhofer 86ef190e 2023-10-14T22:43:25 parser: Fix stack handling in xmlParseTryOrFinish After commit e0dd330b, this latent bug could cause use-after-free errors in rare circumstances like using the reader API with recovery and XIncludes.
Nick Wellnhofer 7dfcea03 2023-10-11T14:19:04 dict: Fix integer overflow in xmlDictAddString Short-lived regression. Older versions didn't check for integer overflow, but limited name length to INT_MAX / 2. Reintroduce this limit. Found by OSS-Fuzz.
Nick Wellnhofer fef12ed8 2023-10-11T13:32:54 buf: Also reset input in error case Avoid dangling pointers if memory allocation failed. This could cause a use-after-free after recent changes. Found by OSS-Fuzz.
Nick Wellnhofer 514ab399 2023-10-11T13:25:49 parser: Don't overwrite error state in xmlParseTextDecl If a memory allocation fails, this could cause a null deref after recent changes. Found by OSS-Fuzz.
Nick Wellnhofer 821a0370 2023-10-09T15:20:00 parser: Fix memory leak in xmlLoadEntityContent Found by OSS-Fuzz.
Nick Wellnhofer 4fc5340e 2023-10-08T14:17:46 parser: Also grow comment buffer if SAX is disabled Fix short-lived regression from 8afd321a, found by OSS-Fuzz.
Nick Wellnhofer 36374bc9 2023-10-08T14:08:44 parser: Fix error handling in xmlLoadEntityContent Backup more members of context struct. Fix small accounting error.
Nick Wellnhofer b76d81da 2023-10-06T11:50:29 parser: Fix regression when push parsing parameter entities Short-lived regression from 834b8123. Also shrink parameter entity buffers when push parsing.
Nick Wellnhofer 134d2ad8 2023-10-06T00:31:44 parser: Protect against quadratic default attribute expansion
Nick Wellnhofer 8afd321a 2023-10-05T22:02:56 parser: Missing checks for disableSAX
Nick Wellnhofer 6337a14a 2023-10-06T10:44:38 tests: Handle entities in SAX tests
Nick Wellnhofer 7615fae6 2023-10-05T23:52:55 parser: Make XML_PARSE_NSCLEAN option work again
Nick Wellnhofer 0ba22c05 2023-10-05T22:05:04 parser: Support encoded external PEs in entity values Corner case which was never supported.
Nick Wellnhofer 713ded60 2023-10-06T10:43:38 entities: Make xmlFreeEntity public
Nick Wellnhofer 97e99f41 2023-10-05T17:11:24 parser: Acknowledge that entities with namespaces are broken Entities which reference out-of-scope namespace have always been broken. xmlParseBalancedChunkMemoryInternal tried to reuse the namespaces currently in scope but these namespaces were ignored by the SAX handler. Besides, there could be different namespaces in scope when expanding the entity again. For example: <!DOCTYPE doc [ <!ENTITY ent "<ns:elem/>"> ]> <doc> <decl1 xmlns:ns="urn:ns1"> &ent; </decl1> <decl2 xmlns:ns="urn:ns2"> &ent; </decl2> </doc> Add some comments outlining possible solutions to this problem. For now, we stop copying namespaces to the temporary parser context in xmlParseBalancedChunkMemoryInternal. This has never really worked and the recent changes contained a partial fix which uncovered other problems like a use-after-free with the XML Reader interface, found by OSS-Fuzz.
Nick Wellnhofer b8e03e13 2023-10-02T15:07:55 examples: Don't use sprintf Avoids warnings on macOS.
Nick Wellnhofer 1734d27d 2023-10-02T15:04:18 encoding: Suppress -Wcast-align warnings
Nick Wellnhofer 71aae4e9 2023-10-02T14:42:51 dict: Compare strings with strncmp Using memcmp can result in OOB reads. Short-lived regression found by OSS-Fuzz.
Nick Wellnhofer eb69c1d3 2023-10-02T12:16:05 parser: Fix initialization of namespace data Move initialization to xmlInitSAXParserCtxt. Also add missing XML_HIDDEN to xmlParserNsFree. Fixes #597.
Nick Wellnhofer fc496793 2023-10-02T12:05:36 parser: Fix error handling in xmlParseQNameHashed Short-lived regression found by OSS-Fuzz.
Nick Wellnhofer 6dd87f5e 2023-09-30T17:11:25 malloc-fail: Fix memory leak in xmlParseBalancedChunkMemoryInternal Short-lived regression found by OSS-Fuzz.
Nick Wellnhofer f0a703da 2023-09-30T17:05:47 dict: Fix null-deref with empty subdict Short lived regression found by OSS-Fuzz.
Nick Wellnhofer 61e29b69 2023-09-30T17:02:46 malloc-fail: Grow hash tables before making allocations Fix short-lived memory leak found by OSS-Fuzz.
Nick Wellnhofer 80a0580f 2023-09-30T15:47:46 xinclude: Expand comment about fuzz timeouts
Nick Wellnhofer fa481873 2023-09-30T14:45:53 fuzz: Disable XML_PARSE_SAX1 option in xml fuzzer There a no plans to fix quadratic behavior in the legacy SAX1 interface.
Nick Wellnhofer 5c150acc 2023-09-29T16:07:45 doc: Add notes about runtest to MAINTAINERS.md
Nick Wellnhofer 06e2f3a4 2023-09-29T13:18:34 legacy: Add private declarations for stubs Required after 8c084ebd.
Nick Wellnhofer 0533daf5 2023-09-29T02:45:20 encoding: Fix infinite loop in xmlCharEncInput Short-lived regression from 95e81a36.
Nick Wellnhofer e0dd330b 2023-09-29T00:18:44 parser: Use hash tables to avoid quadratic behavior Use a hash table to lookup namespaces by prefix. The hash table stores an index into the namespace table. Auxiliary data for namespaces is stored in a separate array along the main namespace table. Use a hash table to verify attribute uniqueness. The hash table stores an index into the attribute table. Reuse hash value from the dictionary to avoid computing them twice. See #346.
Nick Wellnhofer e48f3d8e 2023-09-27T16:47:37 tests: Add more tests for redefined attributes
Nick Wellnhofer a873191c 2023-09-25T14:51:35 parser: Introduce xmlParseQNameHashed
Nick Wellnhofer cb927e85 2023-09-25T14:35:43 parser: Don't skip CR in xmlCurrentChar Skip over carriage returns later in xmlNextChar.
Nick Wellnhofer 19161bab 2023-09-25T14:00:48 dict: Internal API to look up hash values
Nick Wellnhofer d147f564 2023-09-11T05:37:55 dict: Rewrite dictionary hash table code Rewrite the dictionary hash table to use open addressing with Robin Hood probing. See previous commit.
Nick Wellnhofer 4a513d56 2023-09-16T19:12:25 hash: Rewrite hash table code This is a complete rewrite of the code in hash.c Move from a chained hash table implementation to open addressing with Robin Hood probing. This allows to increase the maximum fill factor and further reduce the growth factor, saving considerable amounts of memory without sacrificing performance. To make this work, hash values are now cached in the table entry also avoiding many key comparisons. Tables are created lazily with a smaller minimum size. Insertion functions now report an error if growing the table resulted in a memory allocation failure. Some string comparisons were optimized to call directly into libc instead of using the xmlstring API. The length of inserted keys is computed along with the hash improving allocation performance. Bounds checking was made more robust. In dictionary-based mode, unneeded interning of strings is avoided.
Nick Wellnhofer 4f221a77 2023-09-12T19:08:07 hash: Add hash table tests Make sure to properly test removal from hash tables.
Nick Wellnhofer 1425d8f6 2023-09-16T19:08:10 dict: Separate RNG code
Nick Wellnhofer 42a0bc6d 2023-09-16T19:45:30 tests: Add ATTRIBUTE_NO_SANITIZE_INTEGER macro
Nick Wellnhofer 845bd99f 2023-09-25T00:19:28 string: Fix UTF-8 validation in xmlGetUTF8Char
Nick Wellnhofer 3e7673bc 2023-09-23T17:31:55 malloc-fail: Report malloc failure in xmlFARegExec
Nick Wellnhofer b31813e6 2023-09-28T15:34:08 include: Add more missing stdio.h includes
Nick Wellnhofer b8961a75 2023-09-27T17:22:17 parser: Fix reinitialization
James Le Cuirot c7ff438b 2023-09-10T13:00:31 cmake: Only use pkg-config for .pc files, not for building binaries Using `pkg_check_modules(FOO IMPORTED_TARGET foo)` with `target_link_libraries()` leads to `INTERFACE_LINK_LIBRARIES` in the resulting export file having `\$<LINK_ONLY:PkgConfig::FOO>` rather than the currently expected `\$<LINK_ONLY:FOO::FOO>`, leading to breakage. This can be worked around like so: target_link_libraries(UseFoo PUBLIC "$<BUILD_INTERFACE:PkgConfig::FOO>" INTERFACE "$<INSTALL_INTERFACE:FOO::FOO>" ) However, following some discussion, it is preferable to primarily use find modules as before and only use `pkg_check_modules` for correctly populating the .pc file. Also move `find_package()` calls earlier so that builds fail faster when dependencies are missing.
James Le Cuirot 9d534522 2023-09-10T13:50:18 cmake: Check whether static linking dependencies found in config files If they were required when building libxml2 then they will also be required when statically linking against it. Failing to find them will just lead to undefined references later so detect this early.
James Le Cuirot 8617d8aa 2023-09-10T13:07:49 cmake: Find threads dep early as it may be needed for later checks
Nick Wellnhofer b7d56ef7 2023-09-22T17:03:56 malloc-fail: Report malloc failure in xmlRegEpxFromParse Also check whether malloc failures are reported when fuzzing.
Nick Wellnhofer d94f0b0b 2023-09-22T15:46:11 doc: Update MAINTAINERS and NEWS
Nick Wellnhofer 84e1ffc8 2023-09-22T15:44:17 doc: Don't document internal macros in xmlversion.h
Nick Wellnhofer b9db3d7d 2023-09-22T15:45:20 parser: Simplify xmlStringCurrentChar Start to move away from using this function.
Nick Wellnhofer f98fa863 2023-09-22T15:25:40 regexp: Fix status codes and handle invalid UTF-8 Fixes #561.
Nick Wellnhofer b94283fb 2023-09-22T14:23:27 regexp: Add missing include
Nick Wellnhofer bc4e82ff 2023-09-22T13:37:28 globals: Don't use thread-local storage on Darwin It seems that thread-local storage destructors are run before pthread thread-specific data destructors on Darwin, defeating our scheme to use TSD to clean up TLS. Here's an example program that reports a use-after-free when compiled with `-fsanitize=address` on macOS: #include <pthread.h> typedef struct { int v; } my_struct; static _Thread_local my_struct tls; pthread_key_t key; void dtor(void *tsd) { my_struct *s = (my_struct *) tsd; /* * This will crash ASan, apparently because * TLS has already been freed. */ s->v = 1; } void *thread(void *p) { pthread_setspecific(key, &tls); return NULL; } int main(void) { pthread_key_create(&key, dtor); pthread_t handle; pthread_create(&handle, NULL, thread, NULL); pthread_join(handle, NULL); return 0; }
Nick Wellnhofer 45470611 2023-09-21T23:52:52 error: Make xmlGetLastError return a const error This is a slight break of the API, but users really shouldn't modify the global error struct. The goal is to make xmlLastError use static buffers for its strings eventually. This should warn people if they're abusing the struct.
Nick Wellnhofer fc26934e 2023-09-21T23:29:18 memory: Fix memory debugging with Windows threads On Windows, malloc hooks can be called after the final call to xmlCleanupParser in various tests. This means that xmlMemMutex can still be accessed if memory debugging is enabled, so the mutex should not be cleaned. This also means that tests may report spurious memory leaks on Windows. The old implementation avoided the issue by keeping track of all global state objects in a doubly linked list, so they could be cleaned during xmlCleanupParser. But as far as I can tell all memory will be freed eventually, so this is mostly an issue with our test suite.
Nick Wellnhofer 6eb2a00d 2023-09-21T22:58:02 tests: Update testapi.c
Nick Wellnhofer 8c084ebd 2023-09-21T22:57:33 doc: Make apibuild.py happy
Nick Wellnhofer e4091bcf 2023-09-21T22:54:57 doc: Allow 'unsigned' without 'int'
Nick Wellnhofer 46d7aaec 2023-09-21T22:54:30 doc: Add ignored tokens to apibuild.py
Nick Wellnhofer 6c4ea468 2023-09-21T21:31:52 python: Fix tests Revert part of commit 138213ac.
Nick Wellnhofer 05135536 2023-09-21T20:40:32 globals: Fix build --with-threads --without-output Fixes #593.
Nick Wellnhofer c5890716 2023-09-21T17:01:35 html: Fix logic in htmlAutoClose Note that the function is never called with a NULL newtag. Fixes #591.
Nick Wellnhofer 81741ea4 2023-09-21T16:29:28 xmlreader: Fix EOF detection in xmlTextReaderPushData
Nick Wellnhofer 89ee0369 2023-09-21T15:13:16 python: Fix potential crash in tests/thread2.py Memory debugging must be initialized.
Nick Wellnhofer 72262030 2023-09-21T14:52:14 parser: Readd some includes to parser.h and xmlreader.h Fix backward compatibility.
Nick Wellnhofer 9fc5090c 2023-09-16T19:58:42 hash: Clean up libxml/hash.h Rename variables, fix subincludes, whitespace.
Nick Wellnhofer de4b270a 2023-09-21T14:31:31 autotools: Make --with-minimum disable lzma support Fix an oversight when handling the --with-minimum option.
Nick Wellnhofer f9d717af 2023-09-21T13:05:49 fuzz: Allow to fuzz without push, reader or output modules
Nick Wellnhofer fe1bfb34 2023-09-21T12:33:46 gitlab-ci: Add a "medium" config build Also run CI tests with a build where most modules except a few are disabled. This is the minimum configuration required for libxslt: --with-tree --with-xpath --with-output --with-html Also add --with-threads.
Nick Wellnhofer e7f0d88b 2023-09-21T01:38:26 build: Remove some GCC warnings -Wnested-externs produces spurious warnings after implicit declaration of functions. -Winline is useless since we don't use inlines. -Wredundant-decls was already removed for autotools.
Nick Wellnhofer da274bfa 2023-09-21T01:29:40 build: Fix build when certain modules are disabled
Nick Wellnhofer 9b5cce7a 2023-09-21T00:44:50 include: Remove more unnecessary includes
Nick Wellnhofer f0e8358e 2023-09-20T23:07:58 globals: Final fixes
Nick Wellnhofer d6ba4033 2023-09-20T20:49:59 globals: Move remaining declarations to correct places globals.h is now deprecated. Sanity is restored.
Nick Wellnhofer 1117fae0 2023-09-20T19:20:41 include: Remove unneeded includes
Nick Wellnhofer 736327df 2023-09-20T19:09:15 include: Break inclusion cycle between tree.h and xmlregexp.h
Nick Wellnhofer 699299ca 2023-09-20T18:54:39 globals: Stop including globals.h
Nick Wellnhofer 11a1839d 2023-09-20T17:54:48 globals: Move remaining globals back to correct header files This undoes a lot of damage.
Nick Wellnhofer 7909ff08 2023-09-20T17:38:26 include: Remove unnecessary includes - Don't include tree.h from encoding.h - Don't include parser.h from xmlIO.h
Nick Wellnhofer eb985d6f 2023-09-20T17:17:49 globals: Move error globals back to xmlerror.c
Nick Wellnhofer d1336fd3 2023-09-20T17:00:50 globals: Move malloc hooks back to xmlmemory.h
Nick Wellnhofer a77f9ab8 2023-09-20T16:57:22 globals: Don't include SAX2.h from globals.h
Nick Wellnhofer 2e6c49a7 2023-09-20T14:43:14 globals: Don't store xmlParserVersion in global state This is a constant.
Nick Wellnhofer 0830fcfa 2023-09-20T14:30:12 globals: Deprecate xmlLastError The last error should be accessed with xmlGetLastError.
Nick Wellnhofer db8b9722 2023-09-20T13:56:16 parser: Deprecate global parser options Note that setting global options has no effect anyway when using any of the modern parser API functions which take an option argument like xmlReadMemory or when using xmlCtxtUseOptions. Global options only have an effect when using old API functions xmlParse* or xmlSAXParse* or when using an xmlParserCtxt without calling xmlCtxtUseOptions. Unfortunately, many downstream projects still modify global parser options often without realizing that it has no effect. If necessary, switch to the modern API. Then you can safely remove all code that changes global options. Here's a list of deprecated functions and global variables together with the corresponding parser options. - xmlSubstituteEntitiesDefault, xmlSubstituteEntitiesDefaultValue Parser option XML_PARSE_NOENT - xmlKeepBlanksDefault, xmlKeepBlanksDefaultValue Inverse of parser option XML_PARSE_NOBLANKS - xmlPedanticParserDefault, xmlPedanticParserDefaultValue Parser option XML_PARSE_PEDANTIC - xmlLineNumbersDefault, xmlLineNumbersDefaultValue Always enabled by new API - xmlDoValidityCheckingDefaultValue Parser option XML_PARSE_DTDVALID - xmlGetWarningsDefaultValue Inverse of parser option XML_PARSE_NOWARNING - xmlLoadExtDtdDefaultValue Parser options XML_PARSE_DTDLOAD and XML_PARSE_DTDATTR
Nick Wellnhofer 209516ac 2023-09-20T15:49:03 tests: Don't use deprecated symbols
Nick Wellnhofer 692a5c40 2023-09-20T13:51:26 xmllint: Don't set deprecated globals
Nick Wellnhofer ea29b951 2023-09-20T13:30:01 globals: Abort if lazy allocation of global state failed There's really nothing we can do in this situation, so it's better to abort with an error message.
Nick Wellnhofer 868b94b8 2023-09-20T13:10:29 globals: Reformat libxml/globals.h
Nick Wellnhofer bbf08608 2023-09-20T13:05:02 globals: Move buffer callback declarations to xmlIO.h
Nick Wellnhofer dc3382ef 2023-09-20T12:58:03 globals: Move xmlRegisterNodeDefault to tree.c Code in globals.c must not try to access globals itself since the accessor macros aren't defined and we would only see the main variable.
Nick Wellnhofer 75976742 2023-09-20T12:45:14 globals: Add a few comments
Nick Wellnhofer ecbd634c 2023-09-19T17:21:30 threads: Fix double-checked locking in xmlInitParser Hopefully work around the classic problem with double-checked locking: Another thread could read xmlParserInitialized == 1 but doesn't see other initialization results yet due to compiler or hardware reordering. While unlikely, this seems theoretically possible. The solution is to add a memory barrier after initializing the data but before setting xmlParserInitialized. It might be enough to use a second initialization flag which is only used inside the locked section and update xmlParserInitialized after unlocking. But I haven't seen this approach in many articles discussing this issue, so it's possibly flawed as well.
Nick Wellnhofer f7a403c2 2023-09-19T13:52:53 globals: Move xmlIsMainThread to globals.c xmlIsMainThread is mainly needed for global variables.
Nick Wellnhofer b173b724 2023-09-19T13:17:00 globals: Use thread-local storage if available Also use thread-local storage to store globals on POSIX platforms. Most importantly, this makes sure that global variable access can't fail when allocating the global state struct.
Nick Wellnhofer e7b6ca15 2023-09-18T13:25:06 globals: Rework global state destruction on Windows If DllMain is used, rely on it working as expected. The old code seemed to attempt to free global state of other threads if, for some reason, the DllMain mechanism didn't work. In a static build, register a destructor with RegisterWaitForSingleObject. Make public functions xmlGetGlobalState and xmlInitializeGlobalState no-ops. Move initialization and registration of global state objects to xmlInitGlobalState. Lookup global state with xmlGetThreadLocalStorage which can be inlined nicely. Also cleanup global state when using TLS. xmlLastError must be reset.
Nick Wellnhofer 39a275a5 2023-09-18T21:25:35 globals: Define globals using macros Declare and define globals and helper functions by (ab)using the preprocessor.