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

95 Commits

Author SHA1 Message Date
Nick Wellnhofer
d422b954be Fix pointer/int cast warnings on 64-bit Windows
On 64-bit Windows, `long` is 32 bits wide and can't hold a pointer.
Switch to ptrdiff_t instead which should be the same size as a pointer
on every somewhat sane platform without requiring C99 types like
intptr_t.

Fixes bug 788312.

Thanks to J. Peter Mugaas for the report and initial patch.
2017-10-09 13:47:49 +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
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
David Tardon
074180119f Do not leak the new CData node if adding fails
For https://bugzilla.gnome.org/show_bug.cgi?id=780918
2017-04-07 18:24:52 +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
Daniel Veillard
a6ea72ad19 Fix processing in SAX2 in case of an allocation failure
Related to https://bugzilla.gnome.org/show_bug.cgi?id=731360
2014-07-14 20:29:34 +08:00
Gaurav
3e0eec4319 Adding some missing NULL checks
in SAX2 DOM building code and in the HTML parser
2014-06-13 14:45:20 +08:00
Nicolas Le Cam
52010c639a Compile out use of xmlValidateNCName() when not available.
Fix compilation with minimum and valid.
2014-02-10 10:36:20 +08:00
Nicolas Le Cam
77b5b46409 Legacy needs xmlSAX2StartElement() and xmlSAX2EndElement().
Fix compilation with minimum and legacy.
2014-02-10 10:32:45 +08:00
Gaurav
a885f13a67 Fix a possible NULL dereference
https://bugzilla.gnome.org/show_bug.cgi?id=705400
In case of allocation error the pointer was dereferenced before the
test for a failure
2013-08-03 22:16:02 +08:00
Daniel Veillard
ab0e35044c Activate detection of encoding in external subset
https://bugzilla.gnome.org/show_bug.cgi?id=694228

the ctxt->encoding was percolated down when parsing the external
subset leading to failures
2013-03-27 13:21:38 +08:00
Daniel Veillard
cff2546f13 Cache presence of '<' in entities content
slightly modify how ent->checked is used, and use the lowest bit to
keep the information
2013-03-11 15:59:22 +08:00
Daniel Veillard
a3f1e3e571 Avoid extra processing on entities
If an entity has already been checked for correctness no
need to check it on every reference
2013-03-11 15:59:21 +08:00
Daniel Veillard
6c91aa384f Fix a regression in 2.9.0 breaking validation while streaming
https://bugzilla.gnome.org/show_bug.cgi?id=684774
with help from Kjell Ahlstedt <kjell.ahlstedt@bredband.net>
2012-10-25 15:33:59 +08:00
Daniel Veillard
7651606f31 Various cleanups to avoid compiler warnings 2012-09-11 14:02:08 +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
968a03a2e5 Add support for big line numbers in error reporting
Fix the lack of line number as reported by Johan Corveleyn <jcorvel@gmail.com>

* parser.c include/libxml/parser.h: add an XML_PARSE_BIG_LINES parser
  option not switch on by default, it's an opt-in
* SAX2.c: if XML_PARSE_BIG_LINES is set store the long line numbers
  in the psvi field of text nodes
* tree.c: expand xmlGetLineNo to extract those informations, also
  make sure we can't fail on recursive behaviour
* error.c: in __xmlRaiseError, if a node is provided, call
  xmlGetLineNo() if we can't get a valid line number.
* xmllint.c: switch on XML_PARSE_BIG_LINES in xmllint
2012-08-13 12:41:33 +08:00
Daniel Veillard
740cb1a450 Memory error within SAX2 reuse common framework
There is no reason for that class of errors to not use
the same handling allowing strctured error processing.
2012-07-18 17:48:32 +08:00
Tim Elliott
71a243d5b4 xmlParseNodeInContext problems with an empty document
When you call xmlParseNodeInContext on a fragment node with an
empty document, the parser associates the first new node twice --
once with the document, and once with the fragment node.

This fixes the issue by only associating the new node with the
fragment node.
2012-05-08 13:19:40 +08:00
Pavel Andrejs
8ad4da5f56 HTML element position is not detected propperly
The data in node_seq in xmlParserCtxt was not updated properly
when parsing HTML. This patch fixes the accounting for both
pull and push mode of HTML parsing.
2012-05-08 11:01:12 +08:00
Daniel Veillard
1c989278d9 Fix SAX2 builder in case of undefined attributes namespace
To follow the early XML-1.0 REC, the new localname is "prefix:localname"
and there is obviously now namespace.
2012-01-26 19:43:06 +08:00
Daniel Veillard
77b77b1301 Fix SAX2 builder in case of undefined element namespaces
Work as in XML-1.0 before namespaces, and use prefix:localname
as the new element name (and no namespace of course)
Also fix 3 cases in the regression tests where the prefix: was
erroneously dropped in such case
2012-01-26 19:11:02 +08:00
Daniel Veillard
aa54d37cd7 Fix handling of XML-1.0 XML namespace declaration
Usually 'xml' namespace for XML-1.0 declaration does not need
to be carried but Mike Hommey raised the problem that the SVG
XSD file fails to parse due to a mishandling.
- SAX2.c: failure to create a namespace should not be interpreted
  as a memory allocation error
- tree.c: document better xmlNewNs behaviour, and fix it in the
  case the 'xml' prefix is being used.
2010-09-09 18:17:47 +02:00
Daniel Veillard
06c93b7509 Remove a few warnings 2010-03-15 16:08:44 +01:00
Daniel Veillard
3c080d6d72 Don't give default HTML boolean attribute values in parser
* HTMLparser.c: don't default value of HTML boolean attributes in the
  parser
* SAX2.c: move this to SAX2 tree building backend
* result/HTML/doc2.htm.sax result/HTML/doc3.htm.sax
  result/HTML/wired.html.sax: this changes a few HTML SAX regression
  tests
2010-03-15 15:47:50 +01:00
Daniel Veillard
594e5dfb48 Chasing dead assignments reported by clang-scan
* SAX2.c dict.c error.c hash.c nanohttp.c parser.c python/libxml.c
  relaxng.c runtest.c tree.c valid.c xinclude.c xmlregexp.c xmlsave.c
  xmlschemas.c xpath.c xpointer.c: mostly removing unneded affectations,
  but this led to a few real bugs and some part not yet understood
  (relaxng/interleave)
2009-09-07 14:58:47 +02:00
Daniel Veillard
d44b936499 A few more safety cleanup raised by scan
* SAX2.c encoding.c parser.c xmlschemas.c: a few more safety checks
* relaxng.c: remove an unused intitialization
2009-09-07 12:15:08 +02:00
Daniel Veillard
74eaec1496 502960 provide namespace stack when parsing entity
* parser.c: copy the entity stack
* SAX2.c: fix the warning message for default entities
2009-08-26 15:57:20 +02:00
Daniel Veillard
023d0babc4 Fix leak on SAX1, xmllint --sax1 option and debug
* SAX2.c: don't leak in xmlCheckDefaultedAttributes for standalone
  checking
* xmllint.c: fix xmllint --sax1 to actually use XML_PARSE_SAX1
* debugXML.c: don't raise an error if markup wasn't allocated from
  dictionary if document was parsed with option disabling it
2009-07-29 11:34:50 +02:00
Jim Meyering
669e88c065 potential NULL dereference on non-glibc
* SAX2.c (xmlCheckDefaultedAttributes): When xmlStrdup and/or
  xmlStrcat fails due to OOM avoid printing NULL via a printf-style "%s"
  format
2009-07-29 11:33:32 +02:00
Daniel Veillard
97ff9b367a preparing 0.7.3 release fix a typo in a name Daniel
* configure.in doc/xml.html doc/*: preparing 0.7.3 release
* include/libxml/parserInternals.h SAX2.c: fix a typo in a name
Daniel

svn path=/trunk/; revision=3814
2009-01-18 21:43:30 +00:00
Daniel Veillard
1fb2e0dfc6 add a new define XML_MAX_TEXT_LENGHT limiting the maximum size of a single
* include/libxml/parserInternals.h SAX2.c: add a new define
  XML_MAX_TEXT_LENGHT limiting the maximum size of a single text
  node, the defaultis 10MB and can be removed with the HUGE
  parsing option
Daniel

svn path=/trunk/; revision=3808
2009-01-18 14:08:36 +00:00
Daniel Veillard
1dc9feb00f fix for CVE-2008-4226, a memory overflow when building gigantic text
* SAX2.c parser.c: fix for CVE-2008-4226, a memory overflow
  when building gigantic text nodes, and a bit of cleanup
  to better handled out of memory problem in that code.
* tree.c: fix for CVE-2008-4225, lack of testing leads to
  a busy loop test assuming one have enough core memory.
Daniel

svn path=/trunk/; revision=3803
2008-11-17 15:59:21 +00:00
Daniel Veillard
f4f4e4853a rework the patch to avoid some ABI issue with people allocating entities
* include/libxml/entities.h entities.c SAX2.c parser.c: rework
  the patch to avoid some ABI issue with people allocating
  entities structure directly
Daniel

svn path=/trunk/; revision=3773
2008-08-25 08:57:48 +00:00
Daniel Veillard
ae0765b681 more progresses against the official regression tests small cleanup for
* runxmlconf.c: more progresses against the official regression tests
* runsuite.c: small cleanup for non-leak reports
* include/libxml/tree.h: parsing flags and other properties are
  now added to the document node, this is generally useful and
  allow to make Name and NmToken validations based on the parser
  flags, more specifically the 5th edition of XML or not
* HTMLparser.c tree.c: small side effects for the previous changes
* parser.c SAX2.c valid.c: the bulk of teh changes are here,
  the parser and validation behaviour can be affected, parsing
  flags need to be copied, lot of changes. Also fixing various
  validation problems in the regression tests.
Daniel

svn path=/trunk/; revision=3762
2008-07-31 19:54:59 +00:00
Daniel Veillard
45efd0878a fix line number on text nodes, problem raised by Ralf Junker Daniel
* SAX2.c: fix line number on text nodes, problem raised by Ralf Junker
Daniel

svn path=/trunk/; revision=3751
2008-07-07 13:52:52 +00:00
Daniel Veillard
b242b08831 applied patch from Florent Guilian to remove an useless mutex in the
* dict.c: applied patch from Florent Guilian to remove an
  useless mutex in the xmlDict structure.

older, not commited ...

* SAX2.c: another leak reported by Ashwin
* xinclude.c: fixed the behaviour when XIncluding a fragment
  of the current document, patch from Chris Ryan

Daniel


svn path=/trunk/; revision=3686
2008-02-08 09:56:31 +00:00
Daniel Veillard
dbbd72bd75 fixing bug #319964, parsing of HTML attribute really should not have
* SAX2.c: fixing bug #319964, parsing of HTML attribute really
  should not have namespace processing.
Daniel

svn path=/trunk/; revision=3637
2007-06-12 15:15:52 +00:00
Daniel Veillard
a37a6ad91a trying to fix entities behaviour when using SAX, had to extend entities
* include/libxml/entities.h entities.c SAX2.c parser.c: trying to
  fix entities behaviour when using SAX, had to extend entities
  content and hack on the entities processing code, but that should
  fix the long standing bug #159219
Daniel
2006-10-10 20:05:45 +00:00
Daniel Veillard
b8efdda0a3 add a new function xmlPathToUri() to provide a clean conversion when
* uri.c include/libxml/uri.h: add a new function xmlPathToUri()
  to provide a clean conversion when setting up a base
* SAX2.c tree.c: use said function when setting up doc->URL
  or using the xmlSetBase function. Should fix #346261
Daniel
2006-10-10 12:37:14 +00:00
Daniel Veillard
77aad34c94 refactor to use normal warnings for entities problem and not straight SAX
* SAX2.c: refactor to use normal warnings for entities problem
  and not straight SAX callbacks.
Daniel
2006-07-13 06:21:09 +00:00
Daniel Veillard
2728f845c5 more cleanups based on coverity reports. Daniel
* SAX2.c catalog.c encoding.c entities.c example/gjobread.c
  python/libxml.c: more cleanups based on coverity reports.
Daniel
2006-03-09 16:49:24 +00:00
Daniel Veillard
6977c6c437 fix bug #324432 with <xml:foo/> added to the regression tests Daniel
* SAX2.c: fix bug #324432 with <xml:foo/>
* test/ns7 resul//ns7*: added to the regression tests
Daniel
2006-01-04 14:03:10 +00:00
Daniel Veillard
54f9a4f508 fixing a number of issues raised by xml:id but more generally related to
* SAX2.c tree.c valid.c: fixing a number of issues raised by xml:id
  but more generally related to attributes and ID handling, fixes
  #314358 among other things
Daniel
2005-09-03 13:28:24 +00:00
Daniel Veillard
8874b94cd2 added a parser XML_PARSE_COMPACT option to allocate small text nodes (less
* HTMLparser.c parser.c SAX2.c debugXML.c tree.c valid.c xmlreader.c
  xmllint.c include/libxml/HTMLparser.h include/libxml/parser.h:
  added a parser XML_PARSE_COMPACT option to allocate small
  text nodes (less than 8 bytes on 32bits, less than 16bytes on 64bits)
  directly within the node, various changes to cope with this.
* result/XPath/tests/* result/XPath/xptr/* result/xmlid/*: this
  slightly change the output
Daniel
2005-08-25 13:19:21 +00:00
Daniel Veillard
73da77e0d7 line numbers are now carried by most nodes, fixing xmlGetLineNo() c.f. bug
* SAX2.c tree.c: line numbers are now carried by most nodes, fixing
  xmlGetLineNo() c.f. bug #309205
Daniel
2005-08-24 14:05:37 +00:00
Daniel Veillard
bca3ad25f9 fixed compilation when configured --without-sax1 and other cleanups fixes
* SAX2.c globals.c runtest.c testC14N.c testapi.c tree.c
  include/libxml/SAX2.h include/libxml/xmlregexp.h: fixed compilation
  when configured --without-sax1 and other cleanups fixes bug #172683
* doc/* elfgcchack.h: regenerated
Daniel
2005-08-23 22:14:02 +00:00
Daniel Veillard
24505b0f5c a lot of small cleanups based on Linus' sparse check output. Daniel
* HTMLparser.c SAX2.c encoding.c globals.c parser.c relaxng.c
  runsuite.c runtest.c schematron.c testHTML.c testReader.c
  testRegexp.c testSAX.c testThreads.c valid.c xinclude.c xmlIO.c
  xmllint.c xmlmodule.c xmlschemas.c xpath.c xpointer.c: a lot of
  small cleanups based on Linus' sparse check output.
Daniel
2005-07-28 23:49:35 +00:00
Daniel Veillard
87b3046bc1 first steps toward a testsuite dist fixed bug #307870 Daniel
* Makefile.am: first steps toward a testsuite dist
* SAX2.c include/libxml/xmlerror.h: fixed bug #307870
Daniel
2005-07-05 14:04:36 +00:00
Daniel Veillard
5d4644ef6e revamped the elfgcchack.h format to cope with gcc4 change of aliasing
* doc/apibuild.py doc/elfgcchack.xsl: revamped the elfgcchack.h
  format to cope with gcc4 change of aliasing allowed scopes, had
  to add extra informations to doc/libxml2-api.xml to separate
  the header from the c module source.
* *.c: updated all c library files to add a #define bottom_xxx
  and reimport elfgcchack.h thereafter, and a bit of cleanups.
* doc//* testapi.c: regenerated when rebuilding the API
Daniel
2005-04-01 13:11:58 +00:00