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

4591 Commits

Author SHA1 Message Date
Daniel Veillard
4b4d3d8516 Release of libxml2-2.9.6
* configure.ac doc/xml.html doc/news.html: updated for release
2017-10-06 09:00:53 +02:00
Nick Wellnhofer
0f3b843b35 Fix XPath stack frame logic
Move the calls to xmlXPathSetFrame and xmlXPathPopFrame around in
xmlXPathCompOpEvalPositionalPredicate to make sure that the context
object on the stack is actually protected. Otherwise, memory corruption
can occur when calling sloppily coded XPath extension functions.

Fixes bug 783160.
2017-09-21 17:55:39 +02:00
Nick Wellnhofer
3157cf4e53 Report undefined XPath variable error message
Commit c851970 removed a redundant error message if XPath evaluation
failed. This uncovered a case where an undefined XPath variable error
wasn't reported correctly.

Thanks to Petr Pisar for the report.

Fixes bug 787941.
2017-09-20 16:13:29 +02:00
Nick Wellnhofer
b90d8989d3 Fix regression with librsvg
Instead of using xmlCreateIOParserCtxt, librsvg pushes its own
xmlParserInput on top of a memory push parser. This incorrect use of
the API confuses several parser checks and, since 2.9.5, completely
breaks documents with internal subsets. Work around the problem with
internal subsets.

Thanks to Petr Sumbera for the report:

    https://mail.gnome.org/archives/xml/2017-September/msg00011.html

Also see

    https://bugzilla.gnome.org/show_bug.cgi?id=787895
2017-09-19 16:45:49 +02:00
Nick Wellnhofer
2cdaaab11c Change preprocessor OS tests to __linux__
"linux" without leading underscores is deprecated and less reliable.
2017-09-14 21:30:51 +02:00
Nick Wellnhofer
abbda93c72 Handle more invalid entity values in recovery mode
In attribute content, don't emit entity references if there are
problems with the entity value. Otherwise some illegal entity values
like

    <!ENTITY a '&#38;#x123456789;'>

would later cause problems like integer overflow.

Make xmlStringLenDecodeEntities return NULL on more error conditions
including invalid char refs and errors from recursive calls. Remove
some fragile error checks based on lastError that shouldn't be
needed now. Clear the entity content in xmlParseAttValueComplex if
an error was found.

Found by OSS-Fuzz. Should fix bug 783052.

Also see https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3343
2017-09-13 17:21:04 +02:00
Nick Wellnhofer
c709f3f267 Fix structured validation errors
Also pass 'str2'. Fixes bug 777473.
2017-09-07 19:52:39 +02:00
Nick Wellnhofer
07e227ed00 Fix memory leak in LZMA decompressor 2017-09-07 19:08:43 +02:00
Nick Wellnhofer
e2a9122b8d Set memory limit for LZMA decompression
Otherwise malicious LZMA compressed files could consume large amounts
of memory when decompressed.

According to the xz man page, files compressed with `xz -9` currently
require 65 MB to decompress, so set the limit to 100 MB.

Should fix bug 786696.
2017-09-07 19:08:43 +02:00
Nick Wellnhofer
0fcab658a2 Handle illegal entity values in recovery mode
Make xmlParseEntityValue always return NULL on error. Otherwise some
illegal entity values like

    <!ENTITY e '&%#4294967298;'>

would later cause problems like integer overflow.

Found by OSS-Fuzz. Should fix bug 783052.

Also see

    https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=592
    https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2732
2017-09-07 19:08:43 +02:00
Nick Wellnhofer
ca8635bfc2 Fix debug dump of streaming XPath expressions
The debug function xmlXPathDebugDumpCompExpr would crash when
called with a "streaming" expression.

Fixes bug 787368.
2017-09-07 15:46:12 +02:00
Nick Wellnhofer
3b3d75028a Fix memory leak in nanoftp
Found by OSS-Fuzz (testcase 5487741645094912). Free the user and
password strings in xmlNanoFTPFreeCtxt.

Also see https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2727
2017-09-06 02:11:48 +02:00
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
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.
2017-08-30 14:19:06 +02:00
Daniel Veillard
e29e50e54f Updating the spec file to reflect Fedora 24
new python subpackages namings
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 605899cf22.
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