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

5918 Commits

Author SHA1 Message Date
Nick Wellnhofer
3ff6abbf58 encoding: Rework error codes
Use an enum instead of magic numbers. Fix a few error codes. Simplify
handling of "space" and "partial" errors.

See #506.
2023-04-30 16:43:29 +02:00
Nick Wellnhofer
b463b38bcd .gitignore: Split up and rearrange .gitignore files 2023-04-30 16:22:27 +02:00
Nick Wellnhofer
0260de5568 .gitignore: Add runsuite.log 2023-04-30 16:00:44 +02:00
Nick Wellnhofer
886bf4e63b Stop calling xmlMemoryDump
This was used to check for memory leaks but could potentially create a
.memdump file. These days, there are better ways to check for memory
leaks.
2023-04-30 15:48:41 +02:00
Nick Wellnhofer
fc119e3290 examples: Don't call xmlCleanupParser and xmlMemoryDump
xmlCleanupParser is dangerous and shouldn't be called in most cases.
Being part of the examples led many people to use it incorrectly.

xmlMemoryDump is an obsolete way to test for memory leaks.
2023-04-30 15:48:35 +02:00
Nick Wellnhofer
3da0931811 libxml.m4: Fix "possibly undefined macro" error
See #527.
2023-04-30 13:18:47 +02:00
Luca Niccoli
fdc9cfaa14 cmake: Fix va_copy detection
va_copy is defined by the standard as a macro, so check_function_exists
will not detect it; check_symbol_exists will.

Fixes #528.
2023-04-30 13:18:17 +02:00
Nick Wellnhofer
fa993130f9 xpath: Remove remaining references to valueFrame
Fixes #529.
2023-04-30 13:18:17 +02:00
Nick Wellnhofer
a5bc460583 cmake: Link with --undefined-version 2023-04-29 20:43:54 +02:00
Nick Wellnhofer
a8fe4900be autoconf: Only use --undefined-version with version scripts 2023-04-29 20:17:38 +02:00
Nick Wellnhofer
85d4aba426 libxml.m4: Fix quoting
Should fix #527.
2023-04-29 19:48:50 +02:00
Nick Wellnhofer
d8f6e7602c Link with --undefined-version
lld 16 defaults to --no-undefined-version but the version script can
contain symbols disabled by configuration options.

See #473.
2023-04-29 19:12:23 +02:00
Nick Wellnhofer
131c2dec69 libxml2.syms: Revert removal of version information
Removing version information caused problems when relinking with shared
libraries depending on libxml2. It also broke the ABI on Android.

Revert libxml2.syms to the 2.10.0 version.

Fixes #526.
2023-04-29 18:59:41 +02:00
Nick Wellnhofer
8979d739eb Clean up .gitignore
Remove stuff which probably shouldn't be ignored.
2023-04-28 20:22:05 +02:00
Nick Wellnhofer
e07f765f59 Bump version to 2.12.0 2023-04-28 14:51:06 +02:00
Nick Wellnhofer
f296934ade Release v2.11.0 2023-04-28 14:28:33 +02:00
Nick Wellnhofer
6e12409b33 Regenerate docs and testapi.c 2023-04-26 21:22:17 +02:00
Nick Wellnhofer
2df2562e2b autoconf: Add AC_LANG_SOURCE to fix warning 2023-04-26 21:22:17 +02:00
Nick Wellnhofer
107e00a5be libxml2.syms: Remove LIBXML2_2.11.0 version node
This was never part of a public release and can be removed after commit
bbb2b8f1.
2023-04-26 20:39:53 +02:00
Nick Wellnhofer
3ffcc03b16 parser: Deprecate more internal functions 2023-04-26 20:23:23 +02:00
Nick Wellnhofer
b51b99ef83 testchar: Fix return value in testUserEncoding 2023-04-21 02:56:10 +02:00
Nick Wellnhofer
db32b09d50 xmllint: Validate --maxmem integer option
Fixes #520.
2023-04-20 16:22:11 +02:00
Nick Wellnhofer
250faf3c83 parser: Fix regression in xmlParserNodeInfo accounting
Commit 62150ed2 broke begin_pos and begin_line when extra node info was
recorded.

Fixes #523.
2023-04-20 15:38:00 +02:00
Nick Wellnhofer
eca1116b81 testchar: Add test for memory pull parser with encoding 2023-04-20 15:31:20 +02:00
Nick Wellnhofer
9282b08431 parser: Fix regression in memory pull parser with encoding
Revert another change from commit 98840d40.

Decode the whole buffer when reading from memory and switching to the
initial encoding. Add some comments about potential improvements.
2023-04-19 22:32:19 +02:00
Nick Wellnhofer
1db3567c9d autoconf: Warn about outdated C compilers 2023-04-19 12:19:36 +02:00
Nick Wellnhofer
33fb297b36 encoding: Fix compiler warning in ICU build 2023-04-17 14:59:47 +02:00
David Kilzer
86105c0493 Fix use-after-free in xmlParseContentInternal()
* parser.c:
(xmlParseCharData):
- Check if the parser has stopped before advancing
  `ctxt->input->cur`.  This only occurs if a custom SAX error
  handler calls xmlStopParser() on fatal errors.

Fixes #518.
2023-04-16 12:01:05 -07:00
Nick Wellnhofer
a19fa11e1d parser: Fix regression when switching input encodings
Revert some changes from commit 98840d40.

WebKit/Chromium can actually switch from ISO-8859-1 to UTF-16 in the
middle of parsing. This is a bad idea, but we have to keep supporting
this use case.
2023-04-13 15:20:56 +02:00
Nick Wellnhofer
b4d46cee80 parser: Remove first line handling in xmlParseChunk
After reworking EBCDIC detection, this isn't necessary.
2023-04-12 15:10:01 +02:00
Nick Wellnhofer
921796b06b parser: Don't grow push parser buffers
This should fix a short-lived regression when push parsing with
encodings.
2023-04-12 13:56:33 +02:00
Nick Wellnhofer
547edbf1cb [CVE-2023-29469] Hashing of empty dict strings isn't deterministic
When hashing empty strings which aren't null-terminated,
xmlDictComputeFastKey could produce inconsistent results. This could
lead to various logic or memory errors, including double frees.

For consistency the seed is also taken into account, but this shouldn't
have an impact on security.

Found by OSS-Fuzz.

Fixes #510.
2023-04-11 14:29:59 +02:00
Nick Wellnhofer
e4f85f1bd2 [CVE-2023-28484] Fix null deref in xmlSchemaFixupComplexType
Fix a null pointer dereference when parsing (invalid) XML schemas.

Thanks to Robby Simpson for the report!

Fixes #491.
2023-04-11 14:29:50 +02:00
David Kilzer
cb1b8b8516 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'.
2023-04-10 13:21:53 -07:00
Nick Wellnhofer
d7d0bc6581 SAX2: Ignore namespaces in HTML documents
In commit 21ca8829, we started to ignore namespaces in HTML element
names but we still called xmlSplitQName, effectively stripping the
namespace prefix. This would cause elements like <o:p> being parsed
as <p>. Now we leave the name untouched.

Fixes #508.
2023-03-31 17:08:43 +02:00
Nick Wellnhofer
0e42adce77 parser: Halt parser if switching encodings fails
Avoids buffer overread in htmlParseHTMLAttribute.

Found by OSS-Fuzz.
2023-03-30 14:09:15 +02:00
Nick Wellnhofer
1061537efd malloc-fail: Fix buffer overread with HTML doctype declarations
Found by OSS-Fuzz, see #344.
2023-03-26 22:42:13 +02:00
Nick Wellnhofer
a6b9e55a9e encoding: Fix error code in asciiToUTF8
Use correct error code when invalid ASCII bytes are encountered.

Found by OSS-Fuzz.
2023-03-26 15:42:02 +02:00
Nick Wellnhofer
3660229219 parser: Fix buffer overread in xmlDetectEBCDIC
Short-lived regression found by OSS-Fuzz.
2023-03-26 14:11:31 +02:00
Nick Wellnhofer
7fbd454d9f parser: Grow input buffer earlier when reading characters
Make more bytes available after invoking CUR_CHAR or NEXT.
2023-03-21 21:35:53 +01:00
Nick Wellnhofer
98840d40da parser: Rework EBCDIC code page detection
To detect EBCDIC code pages, we used to switch the encoding twice and
had to be very careful not to decode data after the XML declaration
before the second switch. This relied on a hard-coded expected size of
the XML declaration and was complicated and unreliable.

Now we convert the first 200 bytes to EBCDIC-US and parse the encoding
declaration manually.
2023-03-21 21:35:15 +01:00
Nick Wellnhofer
3eb9f5ca4e parser: Limit name length in xmlParseEncName 2023-03-21 13:19:31 +01:00
Nick Wellnhofer
04d1bedd8c parser: Rework shrinking of input buffers
Don't try to grow the input buffer in xmlParserShrink. This makes sure
that no memory allocations are made and the function always succeeds.

Remove unnecessary invocations of SHRINK. Invoke SHRINK at the end of
DTD parsing loops.

Shrink before growing.
2023-03-21 13:19:18 +01:00
Nick Wellnhofer
44ecefc8cc malloc-fail: Fix buffer overread after htmlParseScript
Found by OSS-Fuzz, see #344.
2023-03-20 15:53:42 +01:00
Nick Wellnhofer
b1319c902f malloc-fail: Check for malloc failures when creating XPath strings
Prevent null derefs.

Found by OSS-Fuzz, see #344.
2023-03-18 16:51:43 +01:00
Nick Wellnhofer
067986fa67 parser: Fix regressions from previous commits
- Fix memory leak in xmlParseNmtoken.
- Fix buffer overread after htmlParseCharDataInternal.
2023-03-18 16:51:40 +01:00
Nick Wellnhofer
9ef2a9abf3 html: Rely on CUR_CHAR to grow the input buffer
- Remove useless invocations of GROW.
- Add some error checks.
- Fix invocations of SHRINK.
2023-03-17 14:14:04 +01:00
Nick Wellnhofer
3e85d7b7ab parser: Rely on CUR_CHAR/NEXT to grow the input buffer
The input buffer is now grown reliably when calling CUR_CHAR
(xmlCurrentChar) or NEXT (xmlNextChar). This allows to remove many
other invocations of GROW.
2023-03-17 14:02:23 +01:00
Nick Wellnhofer
62f199ed7d malloc-fail: Add error check in htmlParseHTMLAttribute
This function must return NULL is an error occurs.

Found by OSS-Fuzz, see #344.
2023-03-17 12:40:46 +01:00
Nick Wellnhofer
c81d0d04bf malloc-fail: Add more error checks when parsing names
xmlParseName and similar functions must return NULL if an error occurs.

Found by OSS-Fuzz, see #344.
2023-03-17 12:39:35 +01:00