1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 12:25:09 +03:00
Commit Graph

7043 Commits

Author SHA1 Message Date
Nick Wellnhofer
02fcb1effb parser: Make xmlParseChunk return an error if parser was stopped
This regressed after enhancing the disableSAX member in 2.13.

Should fix #777.
2024-07-25 17:07:18 +02:00
Nick Wellnhofer
bc14d70f49 xmlsave: Improve "unsupported encoding" error message
Incomplete support of XML_SAVE_* error codes was removed. Error handling
still needs work. xmlOutputBufferCreateFilename should return an error
code.
2024-07-25 00:26:48 +02:00
Nick Wellnhofer
1a89323039 [CVE-2024-40896] Fix XXE protection in downstream code
Some users set an entity's children manually in the getEntity SAX
callback to restrict entity expansion. This stopped working after
renaming the "checked" member of xmlEntity, making at least one
downstream project and its dependants susceptible to XXE attacks.

See #761.
2024-07-24 17:19:32 +02:00
Nick Wellnhofer
6cc2387e1a shell: Only use readline on terminals
Should fix xmllint shell tests.
2024-07-24 12:26:39 +02:00
Nick Wellnhofer
d04e152d9c shell: Remove access(2) checks
The checks didn't handle stdout.

Since unistd.h wasn't included, W_OK wasn't defined and the checks
wouldn't run anyway.
2024-07-24 11:42:32 +02:00
Nick Wellnhofer
aa6ca0b1d3 module: Deprecate module API
This was only used by libxslt which switched to a private
implementation.
2024-07-23 19:57:32 +02:00
Nick Wellnhofer
ec4340b828 Update NEWS 2024-07-23 01:32:43 +02:00
Nick Wellnhofer
e1291059af build: Don't check for pthread.h
The Autotools build still checks for pthread.h (and zlib.h and lzma.h)
but the result isn't needed in config.h.
2024-07-22 23:03:55 +02:00
Nick Wellnhofer
cc03c069f5 build: Don't check for standard POSIX headers
These headers should be available since early POSIX days and are
required no matter what.
2024-07-22 23:02:59 +02:00
Nick Wellnhofer
d7dc2eaf06 build: Don't check for dlfcn.h and dl.h
It's enough to check for symbols.
2024-07-22 21:39:54 +02:00
Nick Wellnhofer
7c10393fc0 build: Fix config.h macros
We have to emulate AC_CHECK_DECLS. Instead of leaving the macro
undefined if a symbol wasn't found, it has to be set to 0.
2024-07-22 17:41:41 +02:00
Nick Wellnhofer
095b3c7faf cmake: Implement READLINE and HISTORY options 2024-07-22 17:03:27 +02:00
Nick Wellnhofer
0172ffa99b build: Only check for required headers 2024-07-22 17:03:27 +02:00
Nick Wellnhofer
3ef6661175 build: Rework mmap checks
Switch to AC_CHECK_DECLS/check_symbol_exists. Don't check for
sys/mman.h separately. Don't check for munmap.
2024-07-22 17:03:27 +02:00
Nick Wellnhofer
e1657f3f27 build: Use AC_CHECK_DECLS/check_symbol_exists for getentropy
This assumes that getentropy is declared in sys/random.h.

Should fix issues on iOS. See #774.
2024-07-22 17:03:27 +02:00
Nick Wellnhofer
278fcf13b9 buf: Limit xmlBuffer size to INT_MAX
Some API functions like xmlBufUse only support ints.
2024-07-22 13:02:07 +02:00
Nick Wellnhofer
6a3c0b0d93 parser: Increase XML_MAX_DICTIONARY_LIMIT
This limit is somewhat arbitrary and can be reached when fuzzing
documents up to 1 MB.

Increase limit to 100 MB and disable limit if XML_PARSE_HUGE is set.
2024-07-22 12:53:00 +02:00
Nick Wellnhofer
d2755cdb6f buf: Fix memory leak if malloc fails before xmlBufBackToBuffer
Short-lived regression.
2024-07-22 12:35:29 +02:00
Nick Wellnhofer
322e733b84 xinclude: Fix fallback for text includes
Fixes #772.
2024-07-18 19:32:23 +02:00
Nick Wellnhofer
0dada8041a threads: Fix 32-bit Windows build
Should fix #771.
2024-07-18 03:48:11 +02:00
Nick Wellnhofer
7b98e8d695 io: Don't call getcwd in xmlParserGetDirectory
The "directory" value isn't used internally. Calling getcwd is
unnecessary and can cause problems in sandboxed environments.

Fixes #770.
2024-07-18 03:22:20 +02:00
Nick Wellnhofer
152021002d buf: Fix maxSize behavior
Short-lived regression.
2024-07-18 03:10:33 +02:00
Nick Wellnhofer
2440cb5dd5 buf: Fix xmlBufBackToBuffer
Short-lived regression.
2024-07-18 03:10:33 +02:00
Nick Wellnhofer
5862e9dd37 Add NULL checks
Short-lived regression.
2024-07-18 02:10:16 +02:00
Nick Wellnhofer
4e93425a7f threads: Prefer Win32 over pthreads 2024-07-16 20:03:01 +02:00
Nick Wellnhofer
1f7d4af355 globals: Clean up macros and add comments 2024-07-16 19:58:09 +02:00
Nick Wellnhofer
4f08a1a249 globals: Also use thread-specific storage on "main" thread
Don't treat "main" thread specially. This simplifies access to
thread-specific data.

xmlGetGlobalState can now also fail on the former main thread, leading
to an unrecoverable condition if malloc fails.

The globals were never defined in public header files when compiling
with thread support. Now they're only defined in a legacy build.

Move TlsFree to DllMain to make cleanup more robust on Windows.

Obsoletes #1.
2024-07-16 19:48:40 +02:00
Nick Wellnhofer
769e5a4a42 threads: Allocate global RMutexes statically
Avoid memory allocations during initialization.
2024-07-16 17:42:10 +02:00
Nick Wellnhofer
5d36664fc9 memory: Deprecate xmlGcMemSetup 2024-07-16 17:42:10 +02:00
Nick Wellnhofer
ff39f28bd7 schematron: Use xmlMalloc 2024-07-16 17:42:10 +02:00
Nick Wellnhofer
a87944e970 windows: Use DllMain for cleanup 2024-07-16 17:42:10 +02:00
Nick Wellnhofer
5f3f66c683 threads: Use pthread_once and InitOnceExecuteOnce
Static initialization flags aren't thread-safe. Also avoids an
allocation on Windows.

TODO: Breaks xmllint on Windows.
2024-07-16 17:42:10 +02:00
Nick Wellnhofer
be250b798f xpath: Remove union swap optimization
This would require locking to make it thread-safe.
2024-07-16 17:42:10 +02:00
Nick Wellnhofer
79e119954c error: Make xmlLastError const 2024-07-16 17:42:10 +02:00
Nick Wellnhofer
eb66d03ef7 io: Deprecate a few functions 2024-07-16 17:42:10 +02:00
Nick Wellnhofer
97680d6c08 io: Rework xmlParserInputBufferGrow
Remove dubious (len != 4) check.

Remove compression-related code. This should already be set when
opening the input.
2024-07-16 17:42:10 +02:00
Nick Wellnhofer
a6f54f055b io: Fine-tune initial IO buffer size 2024-07-16 17:42:10 +02:00
Nick Wellnhofer
7148b77820 parser: Optimize memory buffer I/O
Reenable zero-copy IO for zero-terminated static memory buffers.

Don't stream zero-terminated dynamic memory buffers on top of creating
a copy.
2024-07-16 17:42:10 +02:00
Nick Wellnhofer
34c9108f15 encoding: Add sizeOut argument to xmlCharEncInput
When push parsing, we want to convert as much of the input as possible.
When pull parsing memory buffers, we want to convert data chunk by chunk
to save memory.
2024-07-16 17:42:10 +02:00
Nick Wellnhofer
8e871a31f8 buf: Rework xmlBuffer code
Port most changes made to the xmlBuf code in f3807d76, except that
"size" still includes the terminating NULL byte.

Make xmlSetBufferAllocationScheme, xmlBufferAllocScheme and
xmlDefaultBufferSize no-ops.

Deprecate a few functions.
2024-07-16 17:42:10 +02:00
Nick Wellnhofer
888f70c77e buf: Move xmlBuffer code to buf.c 2024-07-16 17:42:10 +02:00
Nick Wellnhofer
92f30711de parser: Optimize buffer shrinking
Remove checks now that we can shrink memory buffers efficiently.

Shrink more aggressively.
2024-07-16 17:42:10 +02:00
Nick Wellnhofer
a221cd7849 buf: Rework xmlBuf code
Always use what the old implementation called the "IO" allocation
scheme, allowing to move the content pointer past the initial
allocation. This is inexpensive and allows efficient shrinking.

Optimize xmlBufGrow, reusing shrunken memory as much as possible.

Simplify xmlBufAdd.

Make xmlBufBackToBuffer return an error on overflow.

Make "size" exclude the terminating NULL byte.

Always provide an initial size.

Reintroduce static buffers.

Remove xmlBufResize and several other functions.
2024-07-16 17:42:10 +02:00
Nick Wellnhofer
2adcde3920 save: Optimize xmlSerializeText
Use lookup tables.
2024-07-16 17:42:10 +02:00
Nick Wellnhofer
1b06708271 save: Always serialize CR as decimal "
"
We used to serialize CR as "
" when there was no encoding and we
weren't in an attribute. This was somewhat inconsistent.
2024-07-16 17:42:10 +02:00
Nick Wellnhofer
1cfc5b8089 entities: Rework serialization of numeric character references 2024-07-16 17:42:10 +02:00
Nick Wellnhofer
8d1606265d entities: Rework text escaping 2024-07-16 17:42:10 +02:00
Nick Wellnhofer
cc45f618ae save: Rework text escaping
Stop using xmlOutputBufferWriteEscape except when using deprecated
xmlSaveSetEscape. Rewrite xmlOutputBufferWriteEscape to use an extra
buffer and call xmlOutputBufferWrite.

Introduce xmlSerializeText to serialize both text and attribute content.

Don't read encoding from document when serializing and remove all hacks
that temporarily changed the document's encoding.
2024-07-16 17:42:10 +02:00
Nick Wellnhofer
e488695b1a save: Deprecate xmlSaveSet*Escape
xmlSaveSetAttrEscape never had an effect.
2024-07-16 17:42:10 +02:00
Nick Wellnhofer
0ab07b21dd io: Rework xmlOutputBufferWrite
Simplify code, handle short writes from callback.
2024-07-16 17:42:10 +02:00