1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-01-28 17:47:00 +03:00

4679 Commits

Author SHA1 Message Date
Nick Wellnhofer
83fb4119a9 Fix memory leaks in SAX1 parser
Found by OSS-Fuzz. I could only reproduce this with the (obsolete)
SAX1 parser.

One leak is caused by duplicate namespaced attribute names and can be
reproduced in memory mode (testcase 4556417027538944):

    $ cat file
    <d xmlns:a="ns" a:x="v" xmlns:b="ns" b:x="v"/>
    $ xmllint --sax1 --memory file

The other is caused by ATTLISTs with a normalized default for "xmlns"
if they're processed after the entity recursion limit was hit
(testcase 5580750034305024).

    $ cat file
    <!DOCTYPE d [
	<!ENTITY a '<d>&a;'>
	<!ATTLIST d xmlns NMTOKEN 't'>
    ]>
    <d>&a;
    $ xmllint --sax1 --valid file

Also see https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2461
2017-09-06 01:12:34 +02:00
Daniel Veillard
2960178fe8 Release of libxml2-2.9.5
* configure.ac, doc/xslt.html: updated for the release
* doc/*, python/setup.py, testapi.c: regenerated
v2.9.5
2017-09-04 15:38:47 +02:00
Nick Wellnhofer
69936b129f Revert "Print error messages for truncated UTF-8 sequences"
This reverts commit 79c8a6b which caused a serious regression in
streaming mode.

Also reverts part of commit 52ceced "Fix infinite loops with push
parser in recovery mode".

Fixes bug 786554.
v2.9.5-rc2
2017-08-30 14:19:06 +02:00
Daniel Veillard
e29e50e54f Updating the spec file to reflect Fedora 24
new python subpackages namings
v2.9.5-rc1
2017-08-29 12:40:54 +02:00
Bruce Dawson
8f57103793 Add const in five places to move 1 KiB to .rdata
xmlUnicodeBlocks is logically const but was not marked as such. This
fixes that, thus moving it to the read-only data segment.
2017-08-28 21:27:03 +02:00
Daniel Veillard
3daee3f159 Problem resolving relative URIs
Raised by Matthias Pigulla <mp@webfactory.de>

In a nutshell we had that bug on URI composition after some fixes in
the area of localhost empty shortcuts :

./testURI --base file:///some/where file

Without patch: file:/some/file
With patch: file:///some/file
2017-08-28 21:12:14 +02:00
Daniel Veillard
f19385a589 Fix a couple of misleading indentation errors
Raised by gcc as potential error, no semantic change needed but
fixed the indentation
2017-08-28 20:40:19 +02:00
Daniel Veillard
dbb828feb9 Fix missing part of comment for function xmlXPathEvalExpression() 2017-08-28 20:38:53 +02:00
Daniel Veillard
56ec9cef9e Adding README.zOS to list of extra files for the release 2017-08-28 20:15:38 +02:00
Daniel Veillard
afb0f93c12 Revert "Allow build on Visual Studio 2017 community edition for WIN32 on a 64 bit machine."
This reverts commit 605899cf22d185f537eb5efb97a55be30467eb17.
2017-08-28 17:45:47 +02:00
Boris Shtrasman
605899cf22 Allow build on Visual Studio 2017 community edition for WIN32 on a 64 bit machine.
This patch hold the necessary changes to build libxml2 with Visual
Studio 2017 for WIN32 on a 64 bit machine.

Today 64 bit windows installation are very common, and Visual Studio
2017 community is the most recent version i have access to.

I have chosen 32 bit and SDK 8.1 to be as close as possible to Igor Zlatkovic work.
2017-08-28 14:58:21 +02:00
Stéphane Michaut
1056e82e64 Description of work needed to compile on zOS
building on zOS requires Makefile surgery that we cannot
carrry in the common branch, this documents the changes
needed to compile on that platform
2017-08-28 14:45:19 +02:00
Stéphane Michaut
454e397eb7 Porting libxml2 on zOS encoding of code
First set of patches for zOS
- entities.c parser.c tree.c xmlschemas.c xmlschemastypes.c xpath.c xpointer.c:
  ask conversion of code to ISO Latin 1 to avoid having the compiler assume
  EBCDIC codepoint for characters.
- xmlmodule.c: make sure we have support for modules
- xmlIO.c: zOS path names are special avoid dsome of the expectstions from
  Unix/Windows
2017-08-28 14:30:43 +02:00
Nick Wellnhofer
3aca7f31cb Fix unwanted warnings when switching encodings
Revert part of commit 46dc989 "Don't switch encoding for internal
parameter entities" that caused spurious warnings.

Fixes bug 786267.
2017-08-21 13:09:33 +02:00
Daniel Veillard
27f310d453 Fix signature of xmlSchemaAugmentImportedIDC
this is used in a callback which will pass a name, the name is ignored
but it's best to have the signature of the function match, pointed out
by Claude Petit
* xmlschemas.c: fix xmlSchemaAugmentImportedIDC() signature no functional
  change
2017-07-27 14:06:44 +08:00
Patrick Monnerat
d1f9062486 small changes for OS/400
OS/400 version V5R3 is not supported by IBM anymore.
In addition, the iSeries system I have here for development has been changed
and the new system is not able to compile for an OS version lower than V6R1.

Thus I made some updates to the libxml2 os400 scripts accordingly:

- Oldest supported OS version is now V6R1.
- Adjust ILE/RPG wrappers comments.
- Update copyright year range.
- Do not log compiler informational messages.
2017-07-27 11:20:02 +08:00
Nick Wellnhofer
899a5d9f0e Detect infinite recursion in parameter entities
When expanding a parameter entity in a DTD, infinite recursion could
lead to an infinite loop or memory exhaustion.

Thanks to Wei Lei for the first of many reports.

Fixes bug 759579.
2017-07-25 15:21:12 +02:00
David Kilzer
fb56f80eef Heap-buffer-overflow read of size 1 in xmlFAParsePosCharGroup
Credit to OSS-Fuzz.

Add a check to xmlFAParseCharRange() for the end of the buffer
to prevent reading past the end of it.

This fixes Bug 784017.
2017-07-04 18:51:29 +02:00
Nick Wellnhofer
8a0c66986e Fix NULL pointer deref in xmlFAParseCharClassEsc
Found with libFuzzer.
2017-07-04 18:51:29 +02:00
Nick Wellnhofer
52ceced6e7 Fix infinite loops with push parser in recovery mode
Make sure that the input pointer advances in case of errors. Otherwise,
the push parser can loop infinitely.

Found with libFuzzer.
2017-07-04 18:51:29 +02:00
Nick Wellnhofer
f435365b59 Send xmllint usage error to stderr
Fixes bug 781459.
2017-07-04 18:51:28 +02:00
Nick Wellnhofer
3eef3f39a6 Fix NULL deref in xmlParseExternalEntityPrivate
If called from xmlParseExternalEntity, oldctxt is NULL which leads to
a NULL deref if an error occurs. This only affects external code that
calls xmlParseExternalEntity.

Patch from David Kilzer with minor changes.

Fixes bug 780159.
2017-06-20 16:13:57 +02:00
Nick Wellnhofer
872fea9485 Get rid of "blanks wrapper" for parameter entities
Now that replacement of parameter entities goes exclusively through
xmlSkipBlankChars, we can account for the surrounding space characters
there and remove the "blanks wrapper" hack.
2017-06-20 13:19:47 +02:00
Nick Wellnhofer
d9e43c7db5 Make sure not to call IS_BLANK_CH when parsing the DTD
This is required to get rid of the "blanks wrapper" hack. Checking the
return value of xmlSkipBlankChars is more efficient, too.
2017-06-20 13:19:47 +02:00
Nick Wellnhofer
453dff1e3b Remove unnecessary calls to xmlPopInput
It's enough if xmlPopInput is called from xmlSkipBlankChars. Since the
replacement text of a parameter entity is surrounded with space
characters, that's the only place where the replacement can end in a
well-formed document.

This is also required to get rid of the "blanks wrapper" hack.
2017-06-20 13:19:47 +02:00
Nick Wellnhofer
aa267cd127 Simplify handling of parameter entity references
There are only two places where parameter entity references must be
handled. For the internal subset in xmlParseInternalSubset. For the
external subset or content from other external PEs in xmlSkipBlankChars.

Make sure that xmlSkipBlankChars skips over sequences of PEs and
whitespace. Rely on xmlSkipBlankChars instead of calling
xmlParsePEReference directly when in the external subset or a
conditional section.

xmlParserHandlePEReference is unused now.
2017-06-20 13:19:47 +02:00
Nick Wellnhofer
24246c7626 Fix xmlHaltParser
Pop all extra input streams before resetting the input. Otherwise,
a call to xmlPopInput could make input available again.

Also set input->end to input->cur.

Changes the test output for some error tests. Unfortunately, some
fuzzed test cases were added to the test suite without manual cleanup.
This makes it almost impossible to review the impact of later changes
on the test output.
2017-06-20 13:15:43 +02:00
Nick Wellnhofer
e5107772ff Fix pathological performance when outputting charrefs
If a character can't be represented in the output encoding, it is
converted to a character reference. This used to to replace the
character in the input stream by calling xmlBufAddHead or
xmlBufferAddHead. These functions shifted the entire input array
around, leading to quadratic performance when converting a run of
non-representable characters. This is most pronounced when dumping to
memory.

Output the charref directly instead.

Found with libFuzzer.
2017-06-19 16:06:21 +02:00
Nick Wellnhofer
c9ccbd6a6d Deduplicate code in encoding.c
Introduce static functions xmlEncInputChunk and xmlEncOutputChunk
that handle the internal/iconv/ICU branching.
2017-06-19 16:06:21 +02:00
Nick Wellnhofer
5a0ae66d72 Documentation fixes
Fixes bug 347465, bug 599433, bug 624550, bug 698253.
2017-06-18 17:58:38 +02:00
Nick Wellnhofer
8bbe4508ef Spelling and grammar fixes
Fixes bug 743172, bug 743489, bug 769632, bug 782400 and a few other
misspellings.
2017-06-17 16:34:23 +02:00
Nick Wellnhofer
576912fa04 Make HTML parser functions take const pointers
The 'cur' parameter of htmlParseDoc and htmlSAXParseDoc should be
'const xmlChar *'.

Fixes bug 770650.
2017-06-17 15:59:13 +02:00
Nick Wellnhofer
988a5a3b6b Build test programs only when needed
Add test programs to 'check_PROGRAMS' instead of 'noinst_PROGRAMS'.

Fixes bug 760457.
2017-06-17 15:44:50 +02:00
Nick Wellnhofer
b9b4b6b513 Fix doc/examples/index.py
In my previous commit that silenced some test output I didn't realize
that doc/examples/Makefile.am was autogenerated.

Also make index.py output deterministic by sorting the glob results.
2017-06-17 15:43:29 +02:00
Nick Wellnhofer
1f09aea26d Fix compiler warnings in threads.c
Use '#pragma weak' to declare weak functions.
2017-06-17 15:05:34 +02:00
Nick Wellnhofer
629e47e7a2 Fix empty-body warning in nanohttp.c 2017-06-17 14:56:53 +02:00
Nick Wellnhofer
1a595cd173 Fix cast-align warnings
- Suppress warnings in xmlmemory.c by casting to 'void *'.
- Remove unneeded cast in xmlschemas.c that caused a macro precedence
  error.
- Add dummy fields to short structs in xmlschemas.c. This increases the
  size of the structs, but I can't see a better solution without using
  C11's _Alignof operator.

There are still a couple of cast-align warnings in encoding.c. These
are legitimate portability issues that can't be fixed without reworking
the conversion functions.
2017-06-17 14:17:27 +02:00
Nick Wellnhofer
81c01ee9ff Fix unused-parameter warnings 2017-06-17 14:12:53 +02:00
Nick Wellnhofer
1ce1f7852c Fix invalid-source-encoding warnings in testWriter.c
Use hex escapes instead of binary data in source file.
2017-06-17 14:11:03 +02:00
Nick Wellnhofer
5f440d8cad Rework entity boundary checks
Make sure to finish all entities in the internal subset. Nevertheless,
readd a sanity check in xmlParseStartTag2 that was lost in my previous
commit. Also add a sanity check in xmlPopInput. Popping an input
unexpectedly was the source of many recent memory bugs. The check
doesn't mitigate such issues but helps with diagnosis.

Always base entity boundary checks on the input ID, not the input
pointer. The pointer could have been reallocated to the old address.

Always throw a well-formedness error if a boundary check fails. In a
few places, a validity error was thrown.

Fix a few error codes and improve indentation.
2017-06-17 13:25:53 +02:00
Nick Wellnhofer
46dc989080 Don't switch encoding for internal parameter entities
This is only needed for external entities. Trying to switch the encoding
for internal entities could also cause a memory leak in recovery mode.
2017-06-17 13:23:40 +02:00
Nick Wellnhofer
03904159f8 Merge duplicate code paths handling PE references
xmlParsePEReference is essentially a subset of
xmlParserHandlePEReference, so make xmlParserHandlePEReference call
xmlParsePEReference. The code paths in these functions differed
slighty, but the code from xmlParserHandlePEReference seems more solid
and tested.
2017-06-17 13:22:37 +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
David Kilzer
3f0627a1ee Fix duplicate SAX callbacks for entity content
Reset 'was_checked' to prevent entity from being parsed twice and SAX
callbacks being invoked twice if XML_PARSE_NOENT was set.

This regressed in version 2.9.3 and caused problems with WebKit.

Fixes bug 760367.
2017-06-16 21:30:42 +02:00
Nick Wellnhofer
01a4b81a03 Support catalog and threads tests under --without-sax1 2017-06-16 21:27:47 +02:00
Nick Wellnhofer
3939178e4c Treat URIs with scheme as absolute in C14N
Fixes bug 783656.
2017-06-12 20:19:02 +02:00
Nick Wellnhofer
67f9f9d6c8 Misc fixes for 'make tests'
- Silence test output.
- Clean up after doc/examples tests.
- Adjust expected output for script tests.
- Add missing results for relaxng/pattern3

There are still two test failures I can't comment on:

- regexp/bug316338
- schemas/any4_0
2017-06-12 19:46:56 +02:00
Nick Wellnhofer
0b2d5c48e3 Initialize keepBlanks in HTML parser
This caused failures in the HTML push tests but the fix required to
change the expected output of the HTML SAX tests.
2017-06-12 19:11:54 +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
ed48d65b4d Fix copy-paste errors in error messages
Thanks to David Kilzer for the review.
2017-06-11 17:12:21 +02:00