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

129 Commits

Author SHA1 Message Date
Nick Wellnhofer
346c3a930c Remove elfgcchack.h
The same optimization can be enabled with -fno-semantic-interposition
since GCC 5. clang has always used this option by default.
2022-02-20 21:49:04 +01:00
David Kilzer
8f5ccada05 xmlAddChild() and xmlAddNextSibling() may not attach their second argument
Use the return value of xmlAddChild() and xmlAddNextSibling()
instead of the second argument directly.

Found by OSS-Fuzz.

Fixes #316
2022-01-25 16:30:48 +00:00
Nick Wellnhofer
1098c30a04 Fix user-after-free with xmllint --xinclude --dropdtd
The --dropdtd option can leave dangling pointers in entity reference
nodes. Make sure to skip these nodes when processing XIncludes.

This also avoids scanning entity declarations and even modifying
them inadvertently during XInclude processing.

Move from a block list to an allow list approach to avoid descending
into other node types that can't contain elements.

Fixes #237.
2021-04-22 19:44:26 +02:00
Nick Wellnhofer
847a3a1181 Fix use-after-free when XIncluding text from Reader
The XML Reader can free text nodes coming from the XInclude engine
before parsing has finished. Cache a copy of the text string, not the
included node to avoid use after free.

Found by OSS-Fuzz.
2020-09-28 12:37:51 +02:00
Nick Wellnhofer
3fcf319378 Fix regression introduced with commit d88df4b
Revert the commit and use a different approach.

Found by OSS-Fuzz.
2020-08-22 00:50:42 +02:00
Nick Wellnhofer
87d20b554c Fix regression introduced with commit 74dcc10b
The code wasn't dead after all, but I can see no reason in delaying
the XPointer evaluation. This could lead to nodes included earlier
appearing in XPointer results.
2020-08-19 13:52:08 +02:00
Nick Wellnhofer
fbb7fa9a9a Fix memory leak in xmlXIncludeAddNode error paths
Found by OSS-Fuzz.
2020-08-19 13:13:48 +02:00
Nick Wellnhofer
19cae17f5a Revert "Fix quadratic runtime in xi:fallback processing"
This reverts commit 27119ec33c.

Not copying fallback children didn't fix up namespaces and could lead
to use-after-free errors.

Found by OSS-Fuzz.
2020-08-19 13:13:41 +02:00
Nick Wellnhofer
d63cfeca35 Add TODO comment in xinclude.c
Add some thoughts on the major remaining problems with the XInclude
implementation.
2020-08-17 15:42:20 +02:00
Nick Wellnhofer
74dcc10b55 Remove dead code in xinclude.c
'doc' is checked for NULL in xmlXIncludeLoadDoc, so several code
paths can be eliminated.
2020-08-17 03:24:56 +02:00
Nick Wellnhofer
2c74712977 Fix error reporting with xi:fallback
When reporting errors, don't use href of xi:include if xi:fallback
was used. I think this can only be reproduced with
"xmllint --postvalid", see the original bug report:

https://bugzilla.gnome.org/show_bug.cgi?id=152623
2020-08-17 01:17:39 +02:00
Nick Wellnhofer
27119ec33c Fix quadratic runtime in xi:fallback processing
Copying the tree would lead to runtime quadratic in nested fallback
depth, similar to naive string concatenation.
2020-08-17 01:17:39 +02:00
Nick Wellnhofer
d88df4bd48 Fix corner case with empty xi:fallback
xi:fallback could become empty after recursive expansion. Use a flag
to track whether nodes should be skipped.
2020-08-17 01:17:39 +02:00
Nick Wellnhofer
dba82a8c04 Fix XInclude regression introduced with recent commit
The change to xmlXIncludeLoadFallback in commit 11b57459 could
process already freed nodes if text nodes were merged after deleting
nodes with an empty fallback.

Found by OSS-Fuzz.
2020-08-17 01:17:39 +02:00
Nick Wellnhofer
6c128fd58a Fuzz XInclude engine 2020-08-08 14:32:44 +02:00
Nick Wellnhofer
1abf2967f9 Fix exponential runtime and memory in xi:fallback processing
When creating XML_XINCLUDE_START nodes, the children of the original
xi:include node must be freed, otherwise fallback content is copied
twice, doubling runtime and memory consumption for each nested
xi:fallback/xi:include pair.

Found with libFuzzer.
2020-08-07 19:59:07 +02:00
Nick Wellnhofer
11b5745927 Don't process siblings of root in xmlXIncludeProcess
xmlXIncludeDoProcess would follow the siblings of the tree root and
also expand these nodes. When using an XML reader, this could lead to
siblings of the current node being expanded without having been parsed
completely.
2020-08-07 18:51:52 +02:00
Nick Wellnhofer
0f9817c75b Don't recurse into xi:include children in xmlXIncludeDoProcess
Otherwise, nested xi:include nodes might result in a use-after-free
if XML_PARSE_NOXINCNODE is specified.

Found with libFuzzer and ASan.
2020-08-06 14:29:33 +02:00
Nick Wellnhofer
5725c1153a Fix memory leak in xmlXIncludeIncludeNode error paths
Found with libFuzzer and ASan.
2020-08-06 14:29:24 +02:00
Nick Wellnhofer
ff009f9913 Fix memory leak in xmlXIncludeLoadDoc error path
Found by OSS-Fuzz.
2020-05-30 15:43:34 +02:00
Nick Wellnhofer
20c60886e4 Fix typos
Resolves #133.
2020-03-08 17:41:53 +01:00
Jared Yanovich
2a350ee9b4 Large batch of typo fixes
Closes #109.
2019-09-30 18:04:38 +02:00
Nick Wellnhofer
e91cbcf639 Don't read external entities or XIncludes from stdin
The file input callbacks try to read from stdin if "-" is passed as URL.
This should never be done when loading indirect resources like external
entities or XIncludes. Unfortunately, the stdin substitution happens
deep inside the IO code, so we simply replace "-" with "./-" in specific
locations.

This issue also affects other users of the library like libxslt.
Ideally, stdin should only be substituted on explicit request. But more
intrusive changes could break existing code.

Closes #90 and #102.
2019-09-20 13:26:51 +02:00
Nick Wellnhofer
e32afd3fd7 Fix error message when processing XIncludes with fallbacks
Fixes bug #616491
https://bugzilla.gnome.org/show_bug.cgi?id=616491

Based on merge request !41
2019-09-13 15:45:21 +02:00
Wang Kirin
a6a578675b Fix memory leak in xmlXIncludeLoadTxt 2019-08-25 14:12: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
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
Nicolas Le Cam
41586ca667 Fix compilation with minimum and xinclude.
xinclude needs xmlAddNextSibling().
Compile out use of xmlLocationSetPtr when xptr is disabled.
Include xpath header.
2014-02-10 10:36:40 +08:00
Alexey Neyman
0b86537dfa Remove premature XInclude check on URI being relative
As it gives false negatives, see
  https://mail.gnome.org/archives/xml/2013-April/msg00023.html
2013-05-06 10:20:18 +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
Vitaly Ostanin
dce1c8baae Patch for xinclude of text using multibyte characters
for bug https://bugzilla.gnome.org/show_bug.cgi?id=633166

When you xinclude a text file, reading portions (by 4000 bytes) of the
buffer incorrectly handled the situation when the end comes across
portions of the bytes in a multibyte character.
2012-08-17 22:59:44 +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
345ee8b620 Convert XInclude to the new input buffers
A few xmlBuffer...() calls changed to their xmlBuf...() counterparts
2012-07-23 14:24:27 +08:00
Shaun McCance
4cf7325e1f xinclude with parse="text" does not use the entity loader
For https://bugzilla.gnome.org/show_bug.cgi?id=552479

The code for xinclude parse="text" was not using the registered
entity loader, defeating attempts to control loading of files.
2012-05-10 20:59:33 +08:00
Daniel Veillard
06c93b7509 Remove a few warnings 2010-03-15 16:08:44 +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
cb6f525fff 584220 xpointer(/) and xinclude problems
* xinclude.c: xpointer(/) in xinclude could lead to sub-document nodes
  and also fixed the code to inherit the dictionary from the embedding
  document
2009-08-25 19:24:15 +02:00
Stefan Behnel
b9590e9cd2 440226 Add xmlXIncludeProcessTreeFlagsData API
* xinclude.c include/libxml/xinclude.h: new function similar to
  xmlXIncludeProcessFlagsData but operating on a subtree
2009-08-24 19:45:54 +02:00
Daniel Veillard
54bd29b79b patch based on Wieant Nielander contribution to add the option of not
* include/libxml/parser.h xinclude.c xmllint.c: patch based on
  Wieant Nielander contribution to add the option of not doing
  URI base fixup in XInclude
Daniel

svn path=/trunk/; revision=3775
2008-08-26 07:26:55 +00:00
Daniel Veillard
37d2d16c89 patch from Vasily Chekalkin fixes memory leaks, should fix 512647 Daniel
* parser.c xinclude.c: patch from Vasily Chekalkin fixes memory
  leaks, should fix 512647
Daniel

svn path=/trunk/; revision=3706
2008-03-14 10:54:00 +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
William M. Brack
b0a94e8bfa applied patch from bug #454608 from Patrik Fimml. Fixes bug #454608.
* xinclude.c: applied patch from bug #454608 from Patrik Fimml.
  Fixes bug #454608.

svn path=/trunk/; revision=3644
2007-07-18 18:04:55 +00:00
William M. Brack
53ce98cd03 fixed problem with invalid char encountered during text include (reported
* xinclude.c: fixed problem with invalid char encountered during text include (reported on xslt mailing list)

svn path=/trunk/; revision=3583
2007-02-13 00:37:20 +00:00
Daniel Veillard
a658582e1a anothe XInclude user data propagation patch from Michael Day Daniel
* xinclude.c: anothe XInclude user data propagation patch from
  Michael Day
Daniel
2006-12-04 09:21:28 +00:00
Daniel Veillard
681e904e37 fixed a comment applied a patch from Michael Day to add a new function
* xmlsave.c: fixed a comment
* xinclude.c include/libxml/xinclude.h: applied a patch from Michael Day
  to add a new function providing the _private field for the generated
  parser contexts xmlXIncludeProcessFlagsData()
Daniel
2006-09-29 09:16:00 +00:00
Daniel Veillard
bf630c0d8b fix bug #343968, include='text' can't lead to a recursion. Daniel
* xinclude.c: fix bug #343968, include='text' can't lead to a
  recursion.
Daniel
2006-06-06 08:21:41 +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
e0fd93f5d3 fixed bug #302302, nasty but the fix is rather simple. Daniel
* xinclude.c: fixed bug #302302, nasty but the fix is rather simple.
Daniel
2005-08-10 13:39:10 +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
William M. Brack
0b13a091e8 Enhanced handling of xml:base for included elements, fixing bugs 169209
* xinclude.c: Enhanced handling of xml:base for included
  elements, fixing bugs 169209 and 302353.
2005-06-01 03:37:59 +00:00