1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-10 08:58:16 +03:00

4578 Commits

Author SHA1 Message Date
Nick Wellnhofer
e905f08123 Fix more NULL pointer derefs in xpointer.c
Found with afl-fuzz.
2016-10-12 14:00:03 +02:00
Nick Wellnhofer
229d1f93ce Avoid function/data pointer conversion in xpath.c
Fixes a `-pedantic` compiler warning.
2016-10-12 13:23:16 +02:00
Nick Wellnhofer
94613f64c0 Remove unused variables 2016-10-12 13:23:08 +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
c1d1f71211 Disallow namespace nodes in XPointer ranges
Namespace nodes must be copied to avoid use-after-free errors.
But they don't necessarily have a physical representation in a
document, so simply disallow them in XPointer ranges.

Found with afl-fuzz.

Fixes CVE-2016-4658.
2016-10-12 13:12:18 +02:00
Nick Wellnhofer
3f8a91036d Disallow namespace nodes in XPointer points 2016-10-12 13:12:18 +02:00
Nick Wellnhofer
9ab01a277d Fix XPointer paths beginning with range-to
The old code would invoke the broken xmlXPtrRangeToFunction. range-to
isn't really a function but a special kind of location step. Remove
this function and always handle range-to in the XPath code.

The old xmlXPtrRangeToFunction could also be abused to trigger a
use-after-free error with the potential for remote code execution.

Found with afl-fuzz.

Fixes CVE-2016-5131.
2016-10-12 13:12:18 +02:00
Nick Wellnhofer
a005199330 Fix comparison with root node in xmlXPathCmpNodes
This change has already been made in xmlXPathCmpNodesExt but not in
xmlXPathCmpNodes.
2016-10-12 13:09:21 +02:00
Alex Henrie
3169602058 Fix attribute decoding during XML schema validation
For https://bugzilla.gnome.org/show_bug.cgi?id=766834

vctxt->parserCtxt is always NULL in xmlSchemaSAXHandleStartElementNs,
so this function can't call xmlStringLenDecodeEntities to decode the
entities.
2016-08-29 11:21:08 +02:00
Nick Wellnhofer
d8083bf779 Fix NULL pointer deref in XPointer range-to
- Check for errors after evaluating first operand.
- Add sanity check for empty stack.

Found with afl-fuzz.
2016-06-25 14:24:51 +02:00
Nick Wellnhofer
1fc55ca72b Don't print generic error messages in XPath tests 2016-06-25 14:24:51 +02:00
Chun-wei Fan
d77e5fc4bc relaxng.c, xmlschemas.c: Fix build on pre-C99 compilers
Make sure that the variables are declared at the top of the block.

https://bugzilla.gnome.org/show_bug.cgi?id=767063
2016-06-23 19:02:26 +08:00
Daniel Veillard
bdec2183f3 Release of libxml2-2.9.4
* doc/xml.html libxml.spec.in: updated for the release
* doc/*: regenerated but no API additions
v2.9.4
2016-05-23 16:04:52 +08:00
David Kilzer
502f6a6d08 More format string warnings with possible format string vulnerability
For https://bugzilla.gnome.org/show_bug.cgi?id=761029

adds a new xmlEscapeFormatString() function to escape composed format
strings
2016-05-23 15:01:08 +08:00
Daniel Veillard
bdd66182ef Avoid building recursive entities
For https://bugzilla.gnome.org/show_bug.cgi?id=762100

When we detect a recusive entity we should really not
build the associated data, moreover if someone bypass
libxml2 fatal errors and still tries to serialize a broken
entity make sure we don't risk to get ito a recursion

* parser.c: xmlParserEntityCheck() don't build if entity loop
  were found and remove the associated text content
* tree.c: xmlStringGetNodeList() avoid a potential recursion
CVE-2016-3627
2016-05-23 15:01:07 +08:00
Pranjal Jumde
0bcd05c5cd Heap-based buffer overread in htmlCurrentChar
For https://bugzilla.gnome.org/show_bug.cgi?id=758606

* parserInternals.c:
(xmlNextChar): Add an test to catch other issues on ctxt->input
corruption proactively.
For non-UTF-8 charsets, xmlNextChar() failed to check for the end
of the input buffer and would continuing reading.  Fix this by
pulling out the check for the end of the input buffer into common
code, and return if we reach the end of the input buffer
prematurely.
* result/HTML/758606.html: Added.
* result/HTML/758606.html.err: Added.
* result/HTML/758606.html.sax: Added.
* result/HTML/758606_2.html: Added.
* result/HTML/758606_2.html.err: Added.
* result/HTML/758606_2.html.sax: Added.
* test/HTML/758606.html: Added test case.
* test/HTML/758606_2.html: Added test case.
CVE-2016-1833
2016-05-23 15:01:07 +08:00
David Kilzer
0090675905 Heap-based buffer-underreads due to xmlParseName
For https://bugzilla.gnome.org/show_bug.cgi?id=759573

* parser.c:
(xmlParseElementDecl): Return early on invalid input to fix
non-minimized test case (759573-2.xml).  Otherwise the parser
gets into a bad state in SKIP(3) at the end of the function.
(xmlParseConditionalSections): Halt parsing when hitting invalid
input that would otherwise caused xmlParserHandlePEReference()
to recurse unexpectedly.  This fixes the minimized test case
(759573.xml).

* result/errors/759573-2.xml: Add.
* result/errors/759573-2.xml.err: Add.
* result/errors/759573-2.xml.str: Add.
* result/errors/759573.xml: Add.
* result/errors/759573.xml.err: Add.
* result/errors/759573.xml.str: Add.
* test/errors/759573-2.xml: Add.
* test/errors/759573.xml: Add.
2016-05-23 15:01:07 +08:00
Pranjal Jumde
38eae57111 Heap use-after-free in xmlSAX2AttributeNs
For https://bugzilla.gnome.org/show_bug.cgi?id=759020

* parser.c:
(xmlParseStartTag2): Attribute strings are only valid if the
base does not change, so add another check where the base may
change.  Make sure to set 'attvalue' to NULL after freeing it.
* result/errors/759020.xml: Added.
* result/errors/759020.xml.err: Added.
* result/errors/759020.xml.str: Added.
* test/errors/759020.xml: Added test case.
CVE-2016-1835
2016-05-23 15:01:07 +08:00
Pranjal Jumde
11ed4a7a90 Heap use-after-free in htmlParsePubidLiteral and htmlParseSystemiteral
For https://bugzilla.gnome.org/show_bug.cgi?id=760263

* HTMLparser.c: Add BASE_PTR convenience macro.
(htmlParseSystemLiteral): Store length and start position instead
of a pointer while iterating through the public identifier since
the underlying buffer may change, resulting in a stale pointer
being used.
(htmlParsePubidLiteral): Ditto.
CVE-2016-1837
2016-05-23 15:01:07 +08:00
David Kilzer
4472c3a5a5 Fix some format string warnings with possible format string vulnerability
For https://bugzilla.gnome.org/show_bug.cgi?id=761029

Decorate every method in libxml2 with the appropriate
LIBXML_ATTR_FORMAT(fmt,args) macro and add some cleanups
following the reports.
2016-05-23 15:01:07 +08:00
Hugh Davenport
beca86e8c8 Detect change of encoding when parsing HTML names
From https://bugzilla.gnome.org/show_bug.cgi?id=758518

Happens when a file has a name getting parsed, but no valid encoding
set, so libxml has to guess what the encoding is. This patch detects
when the buffer location changes, and if it does, restarts the parsing
of the name.

This slightly change a couple of regression tests output
2016-05-23 15:01:07 +08:00
Daniel Veillard
b1d34de46a Fix inappropriate fetch of entities content
For https://bugzilla.gnome.org/show_bug.cgi?id=761430

libfuzzer regression testing exposed another case where the parser would
fetch content of an external entity while not in validating mode.
Plug that hole
CVE-2016-4449
2016-05-23 15:01:07 +08:00
Pranjal Jumde
45752d2c33 Bug 759398: Heap use-after-free in xmlDictComputeFastKey <https://bugzilla.gnome.org/show_bug.cgi?id=759398>
* parser.c:
(xmlParseNCNameComplex): Store start position instead of a
pointer to the name since the underlying buffer may change,
resulting in a stale pointer being used.
* result/errors/759398.xml: Added.
* result/errors/759398.xml.err: Added.
* result/errors/759398.xml.str: Added.
* test/errors/759398.xml: Added test case.
CVE-2016-1836
2016-05-23 15:01:07 +08: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.
CVE-2016-1839
2016-05-23 15:01:07 +08:00
David Kilzer
db07dd613e Bug 758588: Heap-based buffer overread in xmlParserPrintFileContextInternal <https://bugzilla.gnome.org/show_bug.cgi?id=758588>
* parser.c:
(xmlParseEndTag2): Add bounds checks before dereferencing
ctxt->input->cur past the end of the buffer, or incrementing the
pointer past the end of the buffer.

* result/errors/758588.xml: Add test result.
* result/errors/758588.xml.err: Ditto.
* result/errors/758588.xml.str: Ditto.
* test/errors/758588.xml: Add regression test.
CVE-2016-1838
2016-05-23 15:01:07 +08:00
Pranjal Jumde
cbb271655c Bug 757711: heap-buffer-overflow in xmlFAParsePosCharGroup <https://bugzilla.gnome.org/show_bug.cgi?id=757711>
* xmlregexp.c:
(xmlFAParseCharRange): Only advance to the next character if
there is no error.  Advancing to the next character in case of
an error while parsing regexp leads to an out of bounds access.
CVE-2016-1840
2016-05-23 15:01:07 +08:00
Mattias Hansson
40fd6d2a1b Correct the usage of LDFLAGS
For https://bugzilla.gnome.org/show_bug.cgi?id=761252

It is no longer necessary to save system LDFLAGS when checking
lib specific LDFLAGS.
2016-05-23 14:01:29 +08:00
Mattias Hansson
ebbd2b725f Revert the use of SAVE_LDFLAGS in configure.ac
For https://bugzilla.gnome.org/show_bug.cgi?id=761252

This reverts commit 7dc24965092d7cc310908d6052913050e88ec072.
2016-05-23 13:58:24 +08:00
Daniel Veillard
c97750d11b Avoid an out of bound access when serializing malformed strings
For https://bugzilla.gnome.org/show_bug.cgi?id=766414

* xmlsave.c: xmlBufAttrSerializeTxtContent() if an attribute value
  is not UTF-8 be more careful when serializing it as we may do an
  out of bound access as a result.
CVE-2016-4483
2016-05-23 13:42:18 +08:00
David Kilzer
886529b56c Unsigned addition may overflow in xmlMallocAtomicLoc()
For https://bugzilla.gnome.org/show_bug.cgi?id=764616

This code is used only if turning memory allocation debug
in configure with --with-mem-debug, which should never happen
in real life, so not a serious issue.

* xmlmemory.c:
(MAX_SIZE_T): Macro to define maximum value of size_t.
(xmlMallocAtomicLoc): Add bounds check.  Fix description and use
the correct function name in another error message.
2016-05-23 09:23:22 +08:00
Mike Frysinger
4892005592 libxml2 hardcodes -L/lib in zlib/lzma tests which breaks cross-compiles
For https://bugzilla.gnome.org/show_bug.cgi?id=749416

do not use -L$Z_DIR/lib when Z_DIR isn't actually set
2016-05-23 09:01:00 +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
David Kilzer
5c37382f0f Implement "runtest -u" mode
For https://bugzilla.gnome.org/show_bug.cgi?id=611807

Using "make tests" to add new tests is error prone.
This patch implements a "runtest -u" mode that makes it much
easier to create baselines for new tests.
2016-05-22 09:58:30 +08:00
David Kilzer
d433ea6c83 Integer signed/unsigned type mismatch in xmlParserInputGrow()
For https://bugzilla.gnome.org/show_bug.cgi?id=766635

* parserInternals.c:
(xmlParserInputGrow): Change 'ret' type to 'int' to match the
return type of xmlParserInputBufferGrow().
2016-05-22 09:49:50 +08:00
Pranjal Jumde
8fbbf5513d Bug 763071: heap-buffer-overflow in xmlStrncat <https://bugzilla.gnome.org/show_bug.cgi?id=763071>
* xmlstring.c:
(xmlStrncat): Return NULL if xmlStrlen returns a negative length.
(xmlStrncatNew): Ditto.
CVE-2016-1834
2016-05-22 09:33:57 +08:00
Peter Simons
8f30bdff69 Add missing increments of recursion depth counter to XML parser.
For https://bugzilla.gnome.org/show_bug.cgi?id=765207
CVE-2016-3705
The functions xmlParserEntityCheck() and xmlParseAttValueComplex() used to call
xmlStringDecodeEntities() in a recursive context without incrementing the
'depth' counter in the parser context. Because of that omission, the parser
failed to detect attribute recursions in certain documents before running out
of stack space.
CVE-2016-3705
2016-05-22 09:24:05 +08:00
Michael Paddon
846cf015a7 Integer overflow parsing port number in URI
For https://bugzilla.gnome.org/show_bug.cgi?id=765566

in xmlParse3986Port(), uri->port can overflow when parsing a the port number.
The type of uri->port is int, so the consequent behavior is undefined and
may differ between compilers and architectures
2016-05-21 17:18:15 +08:00
Daniel Veillard
8effcb578e Fix apibuild for a recently added construct
commit c71f9305a99b6aa03cb08fab31106c9c56f1be4f added __XML_EXTERNC
cpp construct which not understood by apibuild, leading to make dist
failures, ask to ignore that construct.
v2.9.4-rc2
2016-05-09 10:31:09 +08:00
Stewart Brodie
45f0abd427 Use pkg-config to locate zlib when possible
For https://bugzilla.gnome.org/show_bug.cgi?id=765979

This fallback to direct detection if not available, but current situation
this is broken for cross compilation
2016-05-09 10:13:12 +08:00
Stewart Brodie
3d75c2e828 Use pkg-config to locate ICU when possible
For https://bugzilla.gnome.org/show_bug.cgi?id=765979

This fallback to icu-config if not available, but current situation
this is broken for cross compilation
2016-05-09 10:11:05 +08:00
Daniel Veillard
34b350048d Fix an error with regexp on nullable counted char transition
This is the first of the two issues raised by Pete Cordell
in https://mail.gnome.org/archives/xml/2016-April/msg00030.html
2016-05-09 09:28:38 +08:00
Nick Wellnhofer
6eb0894a96 Fix memory leak with XPath namespace nodes
Set hasNsNodes to 1 when adding namespace nodes via XP_TEST_HIT.
2016-05-05 17:38:27 +02:00
Nick Wellnhofer
82b73039dc Fix namespace axis traversal
When the namespace axis is traversed in "toBool" mode, the traversal
can exit early, before visiting all nodes. In this case, the XPath
context still contains a non-NULL tmpNsList.

This means that

- the check when to start a new traversal was wrong and
- the tmpNsList could be leaked.

Fixes bug #750037 and, by accident, bug #756075:

https://bugzilla.gnome.org/show_bug.cgi?id=750037
https://bugzilla.gnome.org/show_bug.cgi?id=756075
2016-05-05 15:30:00 +02:00
Daniel Veillard
9b4b8cb3e2 Add a make rule to rebuild for ASAN 2016-05-04 12:33:32 +08:00
Hugh Davenport
b8e0fa3489 Fix null pointer deref in docs with no root element
From https://bugzilla.gnome.org/show_bug.cgi?id=758514
2016-05-04 10:55:49 +08:00
Patrick Monnerat
90da33cebe Portability to non C99 compliant compilers
OS400 C compiler is not C99 compliant.
It only supports local variable declarations at the beginning of a block.
We loose the const as a result but portability is more important.
2016-05-03 21:37:52 +08:00
Patrick Monnerat
c71f9305a9 dict.h: Move xmlDictPtr definition before includes to allow direct inclusion. 2016-05-03 13:52:00 +08:00
Alex Henrie
f6599c5164 Fix XSD validation of URIs with ampersands
For https://bugzilla.gnome.org/show_bug.cgi?id=709171

This makes xmlSchemaSAXHandleStartElementNs pass attributes through
xmlStringDecodeEntities, similar to how xmlSchemaVDocWalk passes them
through xmlNodeListGetString.
2016-05-03 13:25:45 +08:00
Patrick Monnerat
a1dca81df7 xmlschemastypes.c: accept endOfDayFrag Times set to "24:00:00" mean "end of day" and should not cause an error. v2.9.4-rc1 2016-05-01 18:43:40 +08:00
Patrick Monnerat
b29377109b os400: tell about xmllint and xmlcatalog in README400. 2016-05-01 18:36:36 +08:00