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

180 Commits

Author SHA1 Message Date
zhouzhongyuan
0571b4e607 Fix null deref in xmlreader buffer 2019-08-25 13:30:10 +02:00
Nick Wellnhofer
8161b463f5 Remove debug printf in xmlreader.c
Fixes #46.
2019-02-28 12:25:05 +01:00
Nick Wellnhofer
2c8dc7158a Fix null pointer dereference in xmlTextReaderReadOuterXml
Fix a regression caused by commit 39fbfb4f. If xmlTextReaderReadOuterXml
is called on a pristine xmlReader, the current node is NULL and must not
be dereferenced. Move the call to xmlTextReaderExpand to the start of
the function to make sure that we have a valid node.

Fixes #43.
2019-02-25 12:08:48 +01:00
Nick Wellnhofer
26828cb3a1 Fix commit "Memory leak in xmlFreeID (xmlreader.c)"
The recent commit "Memory leak in xmlFreeID (xmlreader.c)" introduced
a double-free.
2019-01-07 18:07:00 +01:00
Nick Wellnhofer
157cd3aed7 Fix NULL pointer deref in xmlTextReaderValidateEntity
Found by OSS-Fuzz.
2019-01-06 14:05:36 +01:00
Nick Wellnhofer
57a3af56f4 Memory leak in xmlFreeTextReader
In error cases, there might still be elements in the vstate table.
Since vstateVPop in valid.c is private, we have to pop the elements
with xmlValidatePopElement. This inspects nodes of the document, so
the reader doc must be freed after the clearing the vstate table.

Found by OSS-Fuzz.
2019-01-06 14:05:36 +01:00
Nick Wellnhofer
efe8c093c4 Memory leak in xmlFreeID (xmlreader.c)
Fix a memory leak in xmlReader's private copy of xmlFreeID. Only
affects validation with NODICT.

Found by OSS-Fuzz.
2019-01-06 14:05:36 +01:00
Nick Wellnhofer
6fc04d714a Revert "Support xmlTextReaderNextSibling w/o preparsed doc"
This reverts commit bfec41b3de which
caused problems with the XML::LibXML Perl bindings.

https://mail.gnome.org/archives/xml/2018-November/msg00010.html
2018-12-01 14:32:58 +01:00
Mohammed Sadiq
c7461f6547 reader: Fix documentation comment 2018-11-29 21:57:45 +01:00
Nick Wellnhofer
39fbfb4fd0 Use actual doc in xmlTextReaderRead*Xml
Otherwise the encoding of the document is ignored and non-ASCII
characters are serialized as numeric references even if the encoding
is specified as UTF-8.
2018-09-25 13:55:46 +02:00
Felix Bünemann
bfec41b3de Support xmlTextReaderNextSibling w/o preparsed doc
This implements missing support for readers that are not based on a
preparsed document in xmlTextReaderNextSibling.
2018-09-01 14:32:25 +02:00
Felix Bünemann
d2ef114c6b Fix xmlTextReaderNext with preparsed document
This fixes the traversal of parent nodes using xmlTextReaderNext()
when the reader is based on a preparsed document (created using
xmlReaderWalker(doc)).

Without this fix the parser will abort even though there are parent
nodes it should traverse to, if it is not currently on an element or
attribute node. This is incorrect, since it can be for example on a
text node when it needs to enter backtracking.
2018-09-01 14:31:34 +02:00
Nick Wellnhofer
e03f0a199a Fix hash callback signatures
Make sure that all parameters and return values of hash callback
functions exactly match the callback function type. This is required
to pass clang's Control Flow Integrity checks and to allow compilation
to asm.js with Emscripten.

Fixes bug 784861.
2017-11-09 16:42:47 +01:00
Nick Wellnhofer
5a0ae66d72 Documentation fixes
Fixes bug 347465, bug 599433, bug 624550, bug 698253.
2017-06-18 17:58:38 +02: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
Jan Pokorný
bb654feb9a Fix typos: dictio{ nn -> n }ar{y,ies}
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2016-04-15 22:22:48 +08:00
Daniel Veillard
213f1fe0d7 CVE-2015-1819 Enforce the reader to run in constant memory
One of the operation on the reader could resolve entities
leading to the classic expansion issue. Make sure the
buffer used for xmlreader operation is bounded.
Introduce a new allocation type for the buffers for this effect.
2015-04-14 17:41:48 +08:00
Daniel Veillard
91309d3a1d Pointer dereferenced before null check
For https://bugzilla.gnome.org/show_bug.cgi?id=707027

A few pointer dereference before NULL check fixed.
Removed a useless test
2014-10-06 20:07:19 +08:00
Gaurav Gupta
d319eb9223 Fix Enum check and missing break
for https://bugzilla.gnome.org/show_bug.cgi?id=737403

In file xmlreader.c
1. An enum is checked to proper value instead of checking like a boolean.
2. Missing break statement added.
2014-10-06 12:24:17 +08:00
Patrick Monnerat
0f7a26d844 Improve va_list portability
Support for va_list declared as an array (cannot be referenced
explicitly)
2013-12-12 15:04:43 +08:00
Daniel Veillard
eea38159be Cleanup on duplicate test expressions
As pointed out by Thomas Jarosch <thomas.jarosch@intra2net.com>

Daniel
2013-01-28 16:55:30 +01:00
Michael Wood
fb27e2cd20 Fix spelling of "length". 2012-10-30 10:18:49 +08:00
Daniel Veillard
f8e3db0445 Big space and tab cleanup
Remove all space before tabs and space and tabs at end of lines.
2012-09-11 13:26:36 +08:00
Daniel Veillard
97fa5b3c8f Fix file and line report for XSD SAX and reader streaming validation
Things now work correctly at the xmllint level:
thinkpad:~/XML -> xmllint --sax --noout --schema test_schema.xsd
test_xml.xml
test_xml.xml:72721: Schemas validity error : Element 'level1': Missing
child element(s). Expected is ( level2 ).
test_xml.xml fails to validate
thinkpad:~/XML -> xmllint --stream --schema test_schema.xsd test_xml.xml
test_xml.xml:72721: Schemas validity error : Element 'level1': Missing
child element(s). Expected is ( level2 ).
test_xml.xml fails to validate
thinkpad:~/XML ->

* error.c: fix a corner case of not reporting lines when we should
* include/libxml/xmlschemas.h doc/symbols.xml: had to add new entry
  points to set the filename on a validation context and a locator
  callback used to fetch the line and file from the context
* xmlschemas.c: add the new entry points xmlSchemaValidateSetFilename()
  and xmlSchemaValidateSetLocator(), plus make sure the error reporting
  routine gets the information if available. Add a locator for SAX.
* xmlreader.c: add and plug a locator for readers.
2012-08-14 11:01:07 +08:00
Daniel Veillard
3e62adbe39 Adding various checks on node type though the API
Specifially checking against namespace nodes before accessing node
pointers
2012-08-09 14:24:02 +08:00
Daniel Veillard
61551a1eb7 Cleanup function xmlBufResetInput() to set input from Buffer
This was scattered in a number of modules, xmlParserInputPtr
have usually their base, cur and end pointer set from an
xmlBuf used as input.
* buf.c buf.h: add a new function implementing this setup
* parser.c HTMLparser.c catalog.c parserInternals.c xmlreader.c
  use the new function instead of digging into the buffer in
  all those modules
2012-07-23 14:24:27 +08:00
Daniel Veillard
8aebce3ec6 Convert XMLReader to the new input buffers
A few direct access were replaced, and also one internal
xmlBuffer structure is converted to use xmlBuf instead
2012-07-23 14:24:27 +08:00
Daniel Veillard
c508fa3f0b Fix a failure to report xmlreader parsing failures
Related to https://bugzilla.gnome.org/show_bug.cgi?id=654567
the problem is that the provided patch failed to raise an error
on xmlTextReaderRead() return when an actual parsing error occured
2012-07-18 17:48:06 +08:00
Andy Lutomirski
9d9685ad88 xmlTextReader bails too quickly on error
For https://bugzilla.gnome.org/show_bug.cgi?id=654567
I use xmlTextReader to parse failed that might be incomplete.  These files are
the beginning of a well-formed file, but the end is missing so the file as a
whole is not well-formed.

The problem is that xmlTextReader starts returning errors when it encounters
the early EOF, even though I haven't finished reading all of the valid data in
the file.  It would be helpful if xmlTextReader kept working until the very
end.
2012-05-15 20:10:25 +08:00
Daniel Veillard
2c437da7f0 Fix a wrong return value in previous patch 2012-05-11 12:08:15 +08:00
Lin Yi-Li
24464be639 Avoid memory leak if xmlParserInputBufferCreateIO fails
For https://bugzilla.gnome.org/show_bug.cgi?id=643949

In case of error on an IO creation input the given context
is terminated with the given close function, except if the
error happened in xmlParserInputBufferCreateIO. This can
lead to a resource leak which is fixed by this patch.
2012-05-10 16:14:55 +08:00
Noam Postavsky
1579499025 add function xmlTextReaderRelaxNGValidateCtxt()
Since there is xmlTextReaderSchemaValidateCtxt() it seems like there
should be an equivalent RelaxNG function. The attached patch adds it.
The code is essentially the same as Schema implementation, but I'm
uncertain as to how to add things to the documentation and test suite:
there seems to be a lot of auto-generation going on.
2012-03-22 10:32:11 +08:00
Rob Richards
5b9dde3eed xmlTextReaderReadOuterXml should handle DTD
* xmlreader.c: fix description of xmlTextReaderReadOuterXml and support DTD
2010-05-05 07:59:44 -04:00
Daniel Veillard
76d364583e Fixing assorted potential problems raised by scan
* encoding.c parser.c relaxng.c runsuite.c tree.c xmlreader.c
  xmlschemas.c: nothing really serious but better safe than sorry
2009-09-07 11:19:33 +02:00
Daniel Veillard
f4653dcd8b 447899 potential double free in xmlFreeTextReader
* xmlreader.c: a document may still be referenced by fakenode,
  just free fakenode before freeing the document.
2009-08-21 18:40:50 +02:00
Daniel Veillard
aacc2a2466 560524 – xmlTextReaderLocalName description
* xmlreader.c: document all functions returning xmlChar * that they
  need to free the result, and some space/tabs cleanups
2009-08-11 18:31:42 +02:00
Daniel Veillard
7e65fad1e3 patch from Riccardo Scussat fixing custom error handlers problems. daniel
* xmlreader.c: patch from Riccardo Scussat fixing custom error
  handlers problems.
daniel

svn path=/trunk/; revision=3795
2008-09-25 14:55:21 +00:00
Daniel Veillard
bfa5cf1ce7 add an --with-coverage configure option and a 'make cov' target based on
* configure.in Makefile.am: add an --with-coverage configure option
  and a 'make cov' target based on gcc profiling and the lcov
  tool. Currently at 68.9% coverage out of 'make check' and 
  runsuite executions.
* xmlreader.c: remove warnings due to C++ comments
Daniel

svn path=/trunk/; revision=3780
2008-08-27 15:33:28 +00:00
Daniel Veillard
aa6de47ebf applied patch from Aswin to fix tree skipping fixed a comment and added a
* xmlreader.c: applied patch from Aswin to fix tree skipping
* include/libxml/entities.h entities.c: fixed a comment and
  added a new xmlNewEntity() entry point
* runtest.c: be less verbose
* tree.c: space and tabs cleanups
daniel

svn path=/trunk/; revision=3774
2008-08-25 14:53:31 +00:00
Daniel Veillard
354cf5c7e4 fix a link to XmlNodeType doc reported by Martijn Arts rebuilt Daniel
* xmlreader.c: fix a link to XmlNodeType doc reported by Martijn Arts
* docs/*: rebuilt
Daniel

svn path=/trunk/; revision=3732
2008-04-07 12:46:48 +00:00
Daniel Veillard
14dad705d5 patch from Ashwin removing duplicate tests Daniel
* xmlreader.c: patch from Ashwin removing duplicate tests
Daniel

svn path=/trunk/; revision=3708
2008-03-14 14:29:40 +00:00
William M. Brack
0c1e301175 corrected small error in last commit corrected small typo in last commit
* configure.in: corrected small error in last commit
* xmlreader.c: corrected small typo in last commit

svn path=/trunk/; revision=3591
2007-03-14 12:40:21 +00:00
Daniel Veillard
a9c5677c22 applied patch from Julien Reichel cleaning up mode and state internal
* xmlreader.c: applied patch from Julien Reichel cleaning up mode
  and state internal flags mixups
Daniel

svn path=/trunk/; revision=3588
2007-03-09 16:59:05 +00:00
William M. Brack
bf9a73d2bb fixed mistake in previous commit (ChangeLog is correct)
svn path=/trunk/; revision=3581
2007-02-09 00:07:07 +00:00
William M. Brack
d46c1ca3fc added a GROW when parsing complex comments (bug #405666) added a hack to
* parser.c: added a GROW when parsing complex comments (bug #405666)
* gentest.py, testapi.c: added a hack to prevent destruction of any
  param with 'destroy' in it's description (i.e. param destroyed by
  the routine under test, so shouldn't be destroyed by testapi)
* xmlreader.c: added freeing of 'input' param even on error

svn path=/trunk/; revision=3579
2007-02-08 23:34:34 +00:00
Daniel Veillard
e96b47fd3d fix xmlTextReaderSetup() description tests which were apparently never
* xmlreader.c: fix xmlTextReaderSetup() description
* test/relaxng/empty1.rng test/relaxng/comps_0.xml
  test/relaxng/empty1_0.xml test/relaxng/comps.rng
  test/relaxng/empty0.rng test/relaxng/empty0_0.xml
  test/relaxng/empty1_1.xml: tests which were apparently 
  never commited to CVS
Daniel

svn path=/trunk/; revision=3572
2007-01-04 17:28:35 +00:00
Aleksey Sanin
d837764002 expose xmlTextReaderSetup function
svn path=/trunk/; revision=3571
2007-01-03 23:13:12 +00:00
Daniel Veillard
11ce4004d8 end of first pass on coverity reports. Daniel
* runtest.c schematron.c testAutomata.c tree.c valid.c xinclude.c
  xmlcatalog.c xmlreader.c xmlregexp.c xpath.c: end of first
  pass on coverity reports.
Daniel
2006-03-10 00:36:23 +00:00
Daniel Veillard
d0271473ab compilation and doc build fixes from Michael Day Daniel
* xmlreader.c include/libxml/xmlreader.h xmlschemas.c: compilation
  and doc build fixes from Michael Day
Daniel
2006-01-02 10:22:02 +00:00
Daniel Veillard
bc4cc9da77 Gary Coady pointed a memory leak in xmlTextReaderReadInnerXml() applied
* xmlreader.c: Gary Coady pointed a memory leak in
  xmlTextReaderReadInnerXml() applied patch fixing #323864
Daniel
2005-12-12 13:26:56 +00:00