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

227 Commits

Author SHA1 Message Date
Nick Wellnhofer
f824a4bd4d Fix memory leak in xmlAllocOutputBufferInternal error path
Thanks to Anish K Kurian for the report. Closes #60.
2019-05-20 13:38:22 +02:00
Nick Wellnhofer
407b393d80 Fix return value of xmlOutputBufferWrite
When using memory buffers, the total size of the buffer was added
again and again, potentially leading to an integer overflow.

Found by OSS-Fuzz.
2019-05-15 13:01:52 +02:00
Nick Wellnhofer
7a1bd7f649 Revert "Change calls to xmlCharEncInput to set flush false"
This reverts commit 6e6ae5daa6 which
broke decoding of larger documents with ICU.

See https://bugs.chromium.org/p/chromium/issues/detail?id=820163
2018-03-17 00:03:24 +01:00
Joel Hockey
6e6ae5daa6 Change calls to xmlCharEncInput to set flush false when not final call. Having flush incorrectly set to true causes errors for ICU. 2018-01-08 19:57:53 +01:00
Nick Wellnhofer
cb5541c9f3 Fix libz and liblzma detection
If libz or liblzma are detected with pkg-config, AC_CHECK_HEADERS must
not be run because the correct CPPFLAGS aren't set. It is actually not
required have separate checks for LIBXML_ZLIB_ENABLED and HAVE_ZLIB_H.
Only check for LIBXML_ZLIB_ENABLED and remove HAVE_ZLIB_H macro.

Fixes bug 764657, bug 787041.
2017-11-27 14:33:37 +01:00
Nick Wellnhofer
86615e43bb Fix IO callback signatures 2017-11-09 17:47:47 +01:00
Vlad Tsyrklevich
28f52fe89d Refactor name and type signature for xmlNop
Update xmlNop's name to xmlInputReadCallbackNop and its type signature
to match xmlInputReadCallback.

Fixes bug 786134.
2017-11-09 13:43:08 +01:00
Nick Wellnhofer
5672397477 Simplify Windows IO functions
Remove "native" non-Unicode functions which were only needed for
pre-NT systems like Windows 95/98.

Don't redefine `stat` but use `struct _stat` and `_stat()` instead.
2017-10-09 16:52:14 +02:00
Nick Wellnhofer
e3890546d7 Fix the Windows header mess
Don't include windows.h and wsockcompat.h from config.h but only when
needed.

Don't define _WINSOCKAPI_ manually. This was apparently done to stop
windows.h from including winsock.h which is a problem if winsock2.h
wasn't included first. But on MinGW, this causes compiler warnings.
Define WIN32_LEAN_AND_MEAN instead which has the same effect.

Always use the compiler-defined _WIN32 macro instead of WIN32.
2017-10-09 14:35:40 +02:00
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
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
5a0ae66d72 Documentation fixes
Fixes bug 347465, bug 599433, bug 624550, bug 698253.
2017-06-18 17:58:38 +02:00
Nick Wellnhofer
81c01ee9ff Fix unused-parameter warnings 2017-06-17 14:12:53 +02:00
Nick Wellnhofer
94f6ce838c Allow zero sized memory input buffers
Useful for a fuzz target I'm working on.
2017-06-10 17:42:04 +02:00
Nick Wellnhofer
030b1f7a27 Revert "Add an XML_PARSE_NOXXE flag to block all entities loading even local"
This reverts commit 2304078555.

The new flag doesn't work and the change even broke the XML_PARSE_NONET
option.
2017-06-06 15:53:42 +02:00
Doran Moppert
2304078555 Add an XML_PARSE_NOXXE flag to block all entities loading even local
For https://bugzilla.gnome.org/show_bug.cgi?id=772726

* include/libxml/parser.h: Add a new parser flag XML_PARSE_NOXXE
* elfgcchack.h, xmlIO.h, xmlIO.c: associated loading routine
* include/libxml/xmlerror.h: new error raised
* xmllint.c: adds --noxxe flag to activate the option
2017-04-07 16:55:05 +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
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
18b8988511 Reenable xz support by default
For https://bugzilla.gnome.org/show_bug.cgi?id=757466

problem was introduced by commit f3f86ff465
for https://bugzilla.gnome.org/show_bug.cgi?id=711026
2015-11-03 15:46:29 +08:00
Daniel Veillard
7a72f4afd5 Fix a couple of issues raised by make dist 2014-10-13 16:23:24 +08:00
Philip Withnall
21699937b0 xmlIO: Handle error returns from dup()
If dup() fails and returns -1, gzdopen() will transparently return NULL,
but then close() will fail after being called on an invalid FD. Change
the code to only call close() on valid FDs.

Coverity issue: #72382
2014-10-06 11:53:39 +08:00
Gaurav Gupta
b8480ae781 Remove a couple of dead conditions
For https://bugzilla.gnome.org/show_bug.cgi?id=733711
2014-07-26 21:14:53 +08:00
Philip Withnall
31aa38158a xmlIO: Fix an FD leak on gzdopen() failure
According to the documentation, gzdopen() does not close the FD on
failure (but does effectively close it on success, since gzclose()
closes it).

Coverity issues: #60440, #60441

https://bugzilla.gnome.org/show_bug.cgi?id=731990
2014-07-26 20:13:11 +08:00
Patrick Monnerat
147aaf21ea Portability fix
Don't assume fileno for stdin and stdout are 0 and 1
2013-12-12 15:02:40 +08:00
Daniel Veillard
63588f476f Fix a regression in xmlGetDocCompressMode()
The switch to xzlib had for consequence that the compression
level of the input was not gathered anymore in ctxt->input->buf,
then the parser compression flags was left to -1 and propagated
to the resulting document.
Fix the I/O layer to get compression detection in xzlib,
then carry it in the input buffer and the resulting document

  This should fix
    https://lsbbugs.linuxfoundation.org/show_bug.cgi?id=3456
2013-05-10 14:01:46 +08:00
Mikhail Titov
8e2098aef7 Fix an output buffer flushing conversion bug
for https://bugzilla.gnome.org/show_bug.cgi?id=694982
On a flush operation, everything must be converted
2013-03-27 11:00:31 +08:00
Daniel Veillard
bf058dce13 Fix the flushing out of raw buffers on encoding conversions
https://bugzilla.gnome.org/show_bug.cgi?id=692915

the new set of converting functions tried to limit the encoding
conversion of the raw buffer to the consumption one to work in
a more progressive fashion. Unfortunately this was bad for
performances and led to errors on progressive parsing when
a very large chunk was close to the end of the document. Fix
the new internal function and switch back to the old way of
converting. Fix another bug in the process.
2013-02-13 18:19:42 +08:00
Daniel Veillard
153cf15905 Fix large parse of file from memory
https://bugzilla.redhat.com/show_bug.cgi?id=862969
The new code trying to detect excessive input lookup would
just get wrong sometimes in the case of very large file parsed
directly from memory.
2012-10-26 13:50:47 +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
Michael Stahl
55b899a23a Support long path names on WNT
so we've got this patch to libxml2 2.7.6 in the LibreOffice code base,
inherited from OOo.  it fixes a definite problem, which is that Windows
has a rather low maximum path length restriction, and there is a special
trick on NT whereby path names can be prefixed with "\\?\", in which
case the maximum length is 32k, which ought to be sufficient even for
bloated office suites :)

I'll attach the patch to the xmlCanonicPath function.  note that i
didn't write this and am by no means an expert on either Microsoftean
platforms or libxml so maybe it's not the best way to do it.
2012-09-07 12:19:25 +08:00
Roumen Petrov
89b6f73aea use xmlBuf... if DEBUG_INPUT is defined 2012-08-07 15:17:31 +08:00
Daniel Veillard
e258adecd0 Provide new accessors for xmlOutputBuffer
To avoid digging into buf->buffer insternal strcuture the two
new entry points xmlOutputBufferGetContent() and
xmlOutputBufferGetSize() should make the ode cleaner.

* include/libxml/xmlIO.h: add two new functions
* xmlIO.c: impement the 2 functions based on the new buffer entry points
2012-08-06 11:16:30 +08:00
Daniel Veillard
a6a6e70c47 Convert xmlIO.c to the new input and output buffers
Relatively mechanical changes, this also led to a couple of fixes
upon review of the I/O code on buffer usage.
2012-07-23 14:24:26 +08:00
Daniel Veillard
adf5ec9496 Cleanups of lzma support
- fix inclusion of the separated file
- use namespaced name for the 4 non-static routines
- add padding after external structures included in-situ
- add new requirement to spec file
- general cleanup of code
2012-01-27 22:19:53 +08:00
Anders F Bjorklund
6bdc774350 move xz/lzma helpers to separate included files 2012-01-27 22:19:52 +08:00
Anders F Bjorklund
eae5261779 add lzma compression support 2012-01-27 22:19:52 +08:00
Mark Adler
a7e79f2868 libxml violates the zlib interface and crashes
* xmlIO.c: remove an abuse of zlib API and use a clean interface
  available in zlib >= 1.2.3
2010-01-19 16:28:48 +01:00
Daniel Veillard
0d5e58f363 542394 xmlRegisterOutputCallbacks MAX_INPUT_CALLBACK
* xmlIO.c: trivial fix, wrong constant
2009-08-24 13:52:23 +02:00
Rob Richards
6c61e0204b Fix windows build 2009-08-12 11:41:27 -04:00
Hans Breuer
2ad41cad3e 574393 – utf-8 filename magic for compressed files
* xmlIO.c: windows specific magic to have UTF-8 file name work with
  compressed files too.
2009-08-11 17:51:22 +02:00
Daniel Veillard
43bc89c1e3 add a missing check in xmlAddSibling, patch by Kris Breuker avoid
* tree.c: add a missing check in xmlAddSibling, patch by Kris Breuker
* xmlIO.c: avoid xmlAllocOutputBuffer using XML_BUFFER_EXACT which
  leads to performances problems especially on Windows.
daniel

svn path=/trunk/; revision=3820
2009-03-23 19:32:04 +00:00
Daniel Veillard
da3fee406d Borland C fix from Moritz Both regenerate, workaround a problem for buffer
* trionan.c: Borland C fix from Moritz Both
* testapi.c: regenerate, workaround a problem for buffer testing
* xmlIO.c HTMLtree.c: new internal entry point to hide even better
  xmlAllocOutputBufferInternal
* tree.c: harden the code around buffer allocation schemes
* parser.c: restore the warning when namespace names are not absolute
  URIs
* runxmlconf.c: continue regression tests if we get the expected
  number of errors
* Makefile.am: run the python tests on make check
* xmlsave.c: handle the HTML documents and trees
* python/libxml.c: convert python serialization to the xmlSave APIs
  and avoid some horrible hacks
Daniel

svn path=/trunk/; revision=3790
2008-09-01 13:08:57 +00:00
Daniel Veillard
1572425c27 preparing 2.7.0 release remove some testing traces remove some warnings
* configure.in, doc/*: preparing 2.7.0 release
* tree.c: remove some testing traces
* parser.c xmlIO.c xmlschemas.c: remove some warnings
Daniel

svn path=/trunk/; revision=3788
2008-08-30 15:01:04 +00:00
Daniel Veillard
e83e93e715 make a new kind of buffer where shrinking and adding in head can avoid
* include/libxml/tree.h tree.c: make a new kind of buffer where
  shrinking and adding in head can avoid reallocation or full
  buffer memmoves
* encoding.c xmlIO.c: use the new kind of buffers for output
  buffers
Daniel

svn path=/trunk/; revision=3787
2008-08-30 12:52:26 +00:00
Daniel Veillard
c4ba8a4221 fix output bug reported by Petr Pajas and analyzed by Bill Daniel
* xmlIO.c: fix output bug reported by Petr Pajas and analyzed by Bill
Daniel

svn path=/trunk/; revision=3695
2008-02-16 10:08:14 +00:00
Rob Richards
f779da3172 fixed windows path determination (patch from Roland Schwarz, bug #462877)
* xmlIO.c: fixed windows path determination (patch from
  Roland Schwarz, bug #462877)
* win32/Makefile.mingw win32/configure.js: fixed mingw build
  (patch from Roland Schwarz, bug #462877)

svn path=/trunk/; revision=3648
2007-08-14 09:41:21 +00:00
Daniel Veillard
5cdbbd2c75 workaround misgenerated file: URIs c.f. #437385 daniel
* xmlIO.c: workaround misgenerated file: URIs c.f. #437385
daniel

svn path=/trunk/; revision=3630
2007-06-12 09:39:14 +00:00
William M. Brack
38d452ac1c Fixed typo in xmlCharEncFirstLine pointed out by Mark Rowe (bug #440159)
* encoding.c: Fixed typo in xmlCharEncFirstLine pointed out
  by Mark Rowe (bug #440159)
* include/libxml/xmlversion.h.in: Added check for definition of
  _POSIX_C_SOURCE to avoid warnings on Apple OS/X (patch from
  Wendy Doyle and Mark Rowe, bug #346675)
* schematron.c, testapi.c, tree.c, xmlIO.c, xmlsave.c: minor
  changes to fix compilation warnings - no change to logic.

svn path=/trunk/; revision=3618
2007-05-22 16:00:06 +00:00
Daniel Veillard
59d3ed8fe0 applied patch from Andreas Stricke to ease the compilation on Windows CE
* catalog.c libxml.h win32/wince/wincecompat.h win32/wince/wincecompat.c
  xmlIO.c nanohttp.c nanoftp.c trio.c triostr.c triostr.h: applied 
  patch from Andreas Stricke to ease the compilation on Windows CE
Daniel

svn path=/trunk/; revision=3600
2007-04-17 12:44:58 +00:00
Daniel Veillard
bd672bc5f9 applied change from Michael Day to avoid a problem when compiled without
* xmlIO.c: applied change from Michael Day to avoid a problem when
  compiled without zlib support.
Daniel

svn path=/trunk/; revision=3596
2007-03-30 12:39:25 +00:00