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

111 Commits

Author SHA1 Message Date
Nick Wellnhofer
4f49017e37 tests: Test streaming schema validation 2023-04-30 21:45:39 +02:00
Nick Wellnhofer
0ffc2d82b5 runtest: Skip element name in schema error messages
This makes sure that memory and streaming tests will report the same
messages.
2023-04-30 21:45:39 +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
dd3569eaa5 Remove XMLDECL macro from .c files 2022-12-08 02:43:17 +01:00
Nick Wellnhofer
76c6da4209 error: Make sure that error messages are valid UTF-8
This has caused issues with the Python bindings for a long time.

Should fix #64.
2022-12-04 23:34:19 +01:00
Nick Wellnhofer
05c3a458aa tests: Check that xmlInitParser doesn't allocate memory 2022-11-27 02:11:07 +01:00
Nick Wellnhofer
34a5a4a5e5 tests: Remove unneeded #includes 2022-11-22 16:03:05 +01:00
Nick Wellnhofer
9c63cea5a6 test: Add test for push parser boundaries 2022-11-20 21:27:59 +01:00
Nick Wellnhofer
ea7c9fb5dd xinclude: Don't create result doc for test with errors 2022-10-23 14:27:05 +02:00
Nick Wellnhofer
c99cde3f21 xinclude: Also test error messages
The reader interface with XIncludes is somewhat broken and can generate
different error messages. Start to move tests which are sketchy with
reader to a separate directory.
2022-10-23 14:26:59 +02:00
Nick Wellnhofer
a9669679f5 error: Don't use initGenericErrorDefaultFunc
The code in xmlInitParser did only set the error handler if it was NULL
which should never happen.
2022-09-09 13:52:48 +02:00
Nick Wellnhofer
13a6637815 Remove BeOS support
Haiku shouldn't be affected.
2022-09-04 01:05:51 +02:00
Nick Wellnhofer
caef85633e Move automata test to runtest.c 2022-09-02 18:33:36 +02:00
Nick Wellnhofer
5bffa33a12 Stop including sys/types.h 2022-09-02 18:33:36 +02:00
Nick Wellnhofer
a308c0cdf7 Deprecate old HTML SAX API 2022-08-25 21:04:57 +02:00
Nick Wellnhofer
c61e12739f Fix warnings when testing --with-minimum build
There's no simple way to make the doc/examples tests handle different
configurations. But these tests aren't especially valuable, so remove
the result file checks.
2022-04-21 06:58:14 +02:00
Nick Wellnhofer
4612ce3031 Implement xpath1() XPointer scheme
See https://www.w3.org/2005/04/xpointer-schemes/
2022-04-21 04:26:52 +02:00
Nick Wellnhofer
670701075b Add configuration flag for XPointer locations support
Add a new configuration flag that controls whether the outdated support
for XPointer locations (ranges and points) is enabled.

    --with-xptr-locs          # Autotools
    LIBXML2_WITH_XPTR_LOCS    # CMake

The latest spec for what it essentially an XPath extension seems to be
this working draft from 2002:

    https://www.w3.org/TR/xptr-xpointer/

The xpointer() scheme is listed as "being reviewed" in the XPointer
registry since at least 2006. libxml2 seems to be the only modern
software that tries to implement this spec, but the code has many bugs
and quality issues.

The flag defaults to "off" and support for this extensions has to be
requested explicitly. The relevant API functions are deprecated.
2022-04-21 02:41:58 +02:00
Nick Wellnhofer
7204dbb0ad Don't mix declarations and code in runtest.c 2022-04-13 16:51:49 +02:00
Nick Wellnhofer
48f191e7d7 Fix schemas and relaxng tests
Run all tests in runtest.c with warnings. This is required to match the
schema validation output from xmllint and doesn't seem to cause any
problems.

Fix the .xml file pattern.

Check parser errors. Print xmllint message if Relax-NG schema can't be
parsed.
2022-04-04 04:28:15 +02:00
Nick Wellnhofer
5ce893c0c4 Move regexp tests to runtest 2022-04-04 04:28:15 +02:00
Nick Wellnhofer
f1c32b4c78 Allow missing result files in runtest
Treat missing files as empty.
2022-04-04 04:28:15 +02:00
Nick Wellnhofer
95c7f315ab Move SVG tests to runtest.c
Also update the test results for the first time since 2000.
2022-04-04 04:18:07 +02:00
David Seifert
865520f048 Respect --sysconfdir in source files
* Prefix installations need to point to a non-root `etc`
  - Gentoo Prefix has been patching this for over 10 years:
    https://bugs.gentoo.org/317891
  - MacPorts has to manually replace paths after patching:
    cc3bb736e9/textproc/libxml2/Portfile (L46)
2022-03-30 14:36:49 +00:00
Nick Wellnhofer
2489c1d024 Remove useless __CYGWIN__ checks
From what I can tell, some really early Cygwin versions from around
1998-2000 used to erroneously define _WIN32. This was eventually fixed,
but these days, the `defined(_WIN32) && !defined(__CYGWIN__)` idiom is
unnecessary.

Now, we only check for __CYGWIN__ in xmlexports.h when deciding whether
to use __declspec.
2022-02-28 22:58:35 +01:00
Nick Wellnhofer
b057239b3f More fixes to --without-valid build
Fix runtest and Python bindings when building --without-valid.

The Python tests still fail. There doesn't seem to be a mechanism to
disable tests depending on feature flags.
2022-02-22 11:52:38 +01:00
Nick Wellnhofer
21217dd94c Add explicit casts in runtest.c
Avoids integer conversion warnings with UBSan.
2022-01-25 03:07:30 +01:00
Finn Barber
87a9927042 Added regression tests for xmlReadFd() and htmlReadFd() 2022-01-16 15:32:45 +01:00
Nick Wellnhofer
e1c2d0adf0 Fix memory leak in runtest.c 2020-08-17 01:17:39 +02:00
Markus Rickert
e6ba4bd775 Add command line option for temp directory in runtest 2020-07-12 18:33:35 +02:00
Nick Wellnhofer
f20daa9e51 Enable error tests with entity substitution 2020-02-11 17:36:43 +01:00
Daniel Richard G
1fda32480c Fix exponent digits when running tests under old MSVC
Switch printf output format to two-digit exponent under certain MSVC
versions.

Closes #111.
2019-10-14 16:48:32 +02:00
Jared Yanovich
2a350ee9b4 Large batch of typo fixes
Closes #109.
2019-09-30 18:04:38 +02:00
Daniel Richard G
6c91dd9495 Don't call printf with NULL string in runtest.c
Avoids undefined behavior causing problems on HP-UX and Solaris.

Closes #78.
2019-08-02 13:18:13 +02:00
Nick Wellnhofer
dcae579eca Remove unneeded function pointer casts 2019-01-06 14:25:18 +01:00
Nick Wellnhofer
8919885ff9 Fix -Wformat-truncation warnings (GCC 8) 2019-01-06 14:24:59 +01:00
Nick Wellnhofer
dc6d2a4987 Don't run icu_parse_test if EUC-JP is unsupported
Closes: #25
2018-09-04 17:13:29 +02:00
Nick Wellnhofer
4b4135977e Skip EBCDIC tests if EBCDIC isn't supported
Fixes bug 603432.
2017-11-04 15:25:30 +01:00
Nick Wellnhofer
cf820462b7 Rework handling of return values in thread tests
Pass a struct to each thread that contains the filename and the return
value. This avoids casting a DWORD to a pointer on Windows.
2017-10-21 14:52:35 +02:00
Nick Wellnhofer
82e0394d46 Fix runtest on Windows
Unbuffer the output and fix some compiler warnings.
2017-10-09 14:35:56 +02:00
Nick Wellnhofer
e3890546d7 Fix the Windows header mess
Don't include windows.h and wsockcompat.h from config.h but only when
needed.

Don't define _WINSOCKAPI_ manually. This was apparently done to stop
windows.h from including winsock.h which is a problem if winsock2.h
wasn't included first. But on MinGW, this causes compiler warnings.
Define WIN32_LEAN_AND_MEAN instead which has the same effect.

Always use the compiler-defined _WIN32 macro instead of WIN32.
2017-10-09 14:35:40 +02:00
Nick Wellnhofer
81c01ee9ff Fix unused-parameter warnings 2017-06-17 14:12:53 +02:00
Nick Wellnhofer
dbaab1f369 Test SAX2 callbacks with entity substitution
This detects regressions like bug 760367.
2017-06-16 21:38:57 +02:00
Nick Wellnhofer
01a4b81a03 Support catalog and threads tests under --without-sax1 2017-06-16 21:27:47 +02:00
David Kilzer
85c112a082 Add test cases for bug 758518
test/HTML/758518-entity.html exposed a bug in pushParseTest() in
runtest.c which assumed that an input file was at least 4 bytes long.
That test case is only 3 bytes, so we now take the minimum of 4 bytes
or the length of the test input.  We also now use 'chunkSize' in place
of the hard-coded value '1024' later in the function.
2017-06-12 18:26:11 +02:00
Nick Wellnhofer
e26630548e Fix handling of parameter-entity references
There were two bugs where parameter-entity references could lead to an
unexpected change of the input buffer in xmlParseNameComplex and
xmlDictLookup being called with an invalid pointer.

Percent sign in DTD Names
=========================

The NEXTL macro used to call xmlParserHandlePEReference. When parsing
"complex" names inside the DTD, this could result in entity expansion
which created a new input buffer. The fix is to simply remove the call
to xmlParserHandlePEReference from the NEXTL macro. This is safe because
no users of the macro require expansion of parameter entities.

- xmlParseNameComplex
- xmlParseNCNameComplex
- xmlParseNmtoken

The percent sign is not allowed in names, which are grammatical tokens.

- xmlParseEntityValue

Parameter-entity references in entity values are expanded but this
happens in a separate step in this function.

- xmlParseSystemLiteral

Parameter-entity references are ignored in the system literal.

- xmlParseAttValueComplex
- xmlParseCharDataComplex
- xmlParseCommentComplex
- xmlParsePI
- xmlParseCDSect

Parameter-entity references are ignored outside the DTD.

- xmlLoadEntityContent

This function is only called from xmlStringLenDecodeEntities and
entities are replaced in a separate step immediately after the function
call.

This bug could also be triggered with an internal subset and double
entity expansion.

This fixes bug 766956 initially reported by Wei Lei and independently by
Chromium's ClusterFuzz, Hanno Böck, and Marco Grassi. Thanks to everyone
involved.

xmlParseNameComplex with XML_PARSE_OLD10
========================================

When parsing Names inside an expanded parameter entity with the
XML_PARSE_OLD10 option, xmlParseNameComplex would call xmlGROW via the
GROW macro if the input buffer was exhausted. At the end of the
parameter entity's replacement text, this function would then call
xmlPopInput which invalidated the input buffer.

There should be no need to invoke GROW in this situation because the
buffer is grown periodically every XML_PARSER_CHUNK_SIZE characters and,
at least for UTF-8, in xmlCurrentChar. This also matches the code path
executed when XML_PARSE_OLD10 is not set.

This fixes bugs 781205 (CVE-2017-9049) and 781361 (CVE-2017-9050).
Thanks to Marcel Böhme and Thuan Pham for the report.

Additional hardening
====================

A separate check was added in xmlParseNameComplex to validate the
buffer size.
2017-06-05 18:38:33 +02:00
Nick Wellnhofer
c2545cbb6d Fix format string warnings
Also fixes bug #768199:

https://bugzilla.gnome.org/show_bug.cgi?id=768199
2016-10-12 13:22:57 +02:00
Nick Wellnhofer
1fc55ca72b Don't print generic error messages in XPath tests 2016-06-25 14:24:51 +02:00
Pranjal Jumde
a820dbeac2 Bug 758605: Heap-based buffer overread in xmlDictAddString <https://bugzilla.gnome.org/show_bug.cgi?id=758605>
Reviewed by David Kilzer.

* HTMLparser.c:
(htmlParseName): Add bounds check.
(htmlParseNameComplex): Ditto.
* result/HTML/758605.html: Added.
* result/HTML/758605.html.err: Added.
* result/HTML/758605.html.sax: Added.
* runtest.c:
(pushParseTest): The input for the new test case was so small
(4 bytes) that htmlParseChunk() was never called after
htmlCreatePushParserCtxt(), thereby creating a false positive
test failure.  Fixed by using a do-while loop so we always call
htmlParseChunk() at least once.
* test/HTML/758605.html: Added.
2016-05-23 15:01:07 +08:00
Daniel Veillard
9f2416c617 Add more debugging info to runtest
When there is a failure, indicates what failed instead of just
dumping the tested file name.
2016-05-22 11:14:45 +08:00