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

5131 Commits

Author SHA1 Message Date
Nick Wellnhofer
f872aa1807 Fix handling of ctxt->base in xmlXPtrEvalXPtrPart
Also set ctxt->base when updating ctxt->cur. Always restore ctxt->cur
on error. Avoids integer truncation and wrong column numbers in
xmlXPathErr.

Stop hiding modification of ctxt members behind a macro.

Found with UBSan.
2022-01-25 01:16:00 +01:00
Nick Wellnhofer
97fe12791a Remove wrong tarname from AC_INIT
Remove the "tarname" added in commit 7c0253aa. Having a tarname
including a version number would result in tarballs named
libxml2-2.9.12-2.9.12.tar.gz.

This change also means that documentation will now be installed in
$(datadir)/doc/libxml2 instead of $(datadir)/doc/libxml2-$(version).
Having a version number in the documentation directory doesn't seem
helpful. The new location also matches the default autotools $(docdir).
2022-01-20 16:16:52 +01:00
Nick Wellnhofer
00e618eb0a Remove old devhelp format
See #295.
2022-01-17 21:39:27 +01:00
Nick Wellnhofer
d85245f934 Fix regression with PEs in external DTD
Fix a regression introduced with commit a28f7d87. In some cases,
parameter entity references in external DTDs wouldn't be expanded.

Fixes #306.
2022-01-16 21:56:10 +01:00
Nick Wellnhofer
9f4cb84c62 Fix xmllint --maxmem
xmlMemSetup must be called before initializing the parser, otherwise
some data structures will be allocated with system malloc instead of
our custom allocator. This throws off built-in memory debugging and
sanitizers.
2022-01-16 18:41:58 +01:00
huangduirong
e4c91f7473 Fix Null-deref-in-xmlSchemaGetComponentTargetNs 2022-01-16 16:24:47 +01:00
Nick Wellnhofer
9277abe25b Fix libxml2.doap
Add description.

Change category to "infrastructure". Apparently, "platform" isn't
allowed anymore.

Add programming language.
2022-01-16 16:01:28 +01:00
Finn Barber
87a9927042 Added regression tests for xmlReadFd() and htmlReadFd() 2022-01-16 15:32:45 +01:00
Finn Barber
fe6890e292 Fix htmlReadFd, which was using a mix of xml and html context functions 2022-01-16 15:31:54 +01:00
Nick Wellnhofer
67953a9f11 Fix memory leak in xmlXPathCompNodeTest
Found by Coverity.
2022-01-16 15:30:02 +01:00
Chun-wei Fan
3cc64a88d4 setup.py.in: Try to import setuptools
This way, we can build binary wheels easily if needed
2022-01-16 15:18:06 +01:00
Chun-wei Fan
dbfe6151ff Python distutils: Make DLL packaging more flexible
This updates setup.py.in to pack the DLLs according to the options we specified
to configure.js or CMake (or, even configure, although autotools builds are not
likely to build the libxml2 Python module via distutils).

At this point, we can pack only the DLLs that libxml2 really depends on, and
pack the libxslt DLLs only if we really built the libxslt Python modules.

Also make the DLL filenames more easily configured
2022-01-16 15:18:06 +01:00
Chun-wei Fan
1b7d4e2bcc tstmem.py: Try importing from libxmlmods.libxml2mod if needed
Distutils builds place libxml2mod.pyd under the libxmlmods subdir, so try this
directory if 'import libxml2mod' failed.
2022-01-16 15:18:06 +01:00
Chun-wei Fan
6e169c1490 python: Port python 3.x module to Windows
On Windows, we don't have fcntl() which helps us to find out how a file was
opened, so we need to resort to the Windows API NtQueryInformationFile() in
ntdll.dll to help us, and compare the file access modes as appropriate to
deduce the modes we want to pass into fdopen().

As all official Python 3.x releases are built against newer Windows CRTs that
toughen checks on the validity of the file descriptor when we convert the fd to
a native Windows File Handle using _get_osfhandle(), we need to define an empty
handler so that the program does not abort if the fd that was passed in was
invalid; instead, we just return NULL if _get_osfhandle() could not return us a
valid Windows File Handle.
2022-01-16 15:18:06 +01:00
Mohammad Razavi
eb4c1bf855 Fix random dropping of characters on dumping ASCII encoded XML
Fix a bug in xmlCharEncOutput return value which will cause
xmlNodeDumpOutput to drop characters randomly.

xmlCharEncOutput returns zero if the length of the input buffer is
zero but ignores the fact that it may already encoded the input buffer
and the input's length is zero due to the fact that xmlEncOutputChunk
returned -2 errors and underlying code tries to fix the error by
encoding the input.

xmlCharEncOutput is collecting the number of bytes written to the
output buffer but is returning zero instead of the total number of
bytes in this situation. This commit will fix this issue by returning
the total number of bytes instead. So the xmlNodeDumpOutput will also
continue writing and will not stop due to the fact that it mistakenly
thinks the output buffer is not changed in that iteration.

Fixes #314
2022-01-16 15:08:44 +01:00
Kjell Ahlstedt
66fb340a0d Update URL for libxml++ C++ binding
Fixes #267
2022-01-16 15:07:40 +01:00
Nick Wellnhofer
ae728bb872 Fix null pointer deref in xmlStringGetNodeList
Check for malloc failure to avoid null deref.
2022-01-16 15:05:41 +01:00
Yulin Li
46c658b025 move current position before possible calling of ctxt->sax->characters. 2022-01-16 15:03:12 +01:00
Mattia Rizzolo
9675345048 Correctly install the HTML examples into their subdirectory.
Previous to this commit, the examples where installed haphazardly within
all the other html documents, also overwriting index.html, for example.

Signed-off-by: Mattia Rizzolo <mattia@mapreri.org>
2022-01-16 14:59:02 +01:00
Mattia Rizzolo
7c0253aadf Refactor the settings of $docdir
This is a completely noop change for this project, since before this
commit nothing was using $docdir nor PROGRAM_TARNAME.

Setting the fourth parameter of AC_INIT() makes it set PROGRAM_TARNAME,
which then used as the last path component of the default docdir,
effectively making $docdir be the same as the previous
$BASE_DIR/$DOC_MODULE.

Signed-off-by: Mattia Rizzolo <mattia@mapreri.org>
2022-01-16 14:47:35 +01:00
Ben Boeckel
51c88c6f8d configure: remove unused checks for functions
Nothing uses the results from these checks, so remove the checks. There
are some "uses" in order to suppress macro shadowing in MSVC's
implementation of `isinf` and `isnan` as macros, but those are
hard-coded and do not require checks to manage.
2022-01-16 14:34:37 +01:00
Ben Boeckel
1a013ba711 configure: remove unused checks for libraries
These libraries are queried for, but no code cares about the results, so
remove the checks.
2022-01-16 14:34:37 +01:00
Ben Boeckel
0aad075c6b cmake: remove unused checks
Even the configured `config.h` did not forward the results of these
checks.
2022-01-16 14:34:37 +01:00
Ben Boeckel
9669bd68a3 configure: remove unused checks for headers
These headers are checked for at configure time, but the code never
cares about the results of these checks, so skip them.
2022-01-16 14:34:37 +01:00
Ben Boeckel
f86082359b cmake: fix ATTRIBUTE_DESTRUCTOR definition
The code expects it to be set to the attribute for `xmlDestructor`, but
in CMake, it is only ever available as `1` or undefined. Instead, match
the behavior or autoconf.
2022-01-16 14:34:37 +01:00
Emmanuele Bassi
3ba59b9349 Generate devhelp2 index file
The devhelp2 format was introduced in 2005, and the devhelp format was
deprecated in 2017.

Fixes: https://gitlab.gnome.org/GNOME/libxml2/-/issues/295
2022-01-16 14:32:14 +01:00
David King
91b3d3f95b Remove duplicated code in xmlcatalog
Found by Coverity.

https://bugzilla.redhat.com/show_bug.cgi?id=1938806
2022-01-16 14:28:45 +01:00
David King
d7f11fd066 Fix leak in __xmlOutputBufferCreateFilename
Found by Coverity.

https://bugzilla.redhat.com/show_bug.cgi?id=1938806
2022-01-16 14:26:14 +01:00
David King
477f6de394 Fix memory leak in xmlRelaxNGNewDocParserCtxt
Found by Coverity.

https://bugzilla.redhat.com/show_bug.cgi?id=1938806
2022-01-16 14:24:45 +01:00
David King
483de2c21d Fix memory leak in xmlRelaxNGParseData
Found by Coverity.

https://bugzilla.redhat.com/show_bug.cgi?id=1938806
2022-01-16 14:23:46 +01:00
David King
9a9dd31ba6 Fix memory leak in libxml_C14NDocSaveTo
Found by Coverity.

https://bugzilla.redhat.com/show_bug.cgi?id=1938806
2022-01-16 14:22:26 +01:00
David King
d68c163723 Fix memory leak in libxml_saveNodeTo
Found by Coverity.

https://bugzilla.redhat.com/show_bug.cgi?id=1938806
2022-01-16 14:20:57 +01:00
David King
328456bf29 Fix memory leak in xmlNewInputFromFile
Found by Coverity.

https://bugzilla.redhat.com/show_bug.cgi?id=1938806
2022-01-16 14:15:09 +01:00
David King
fe564967c9 Fix memory leak in xmlCreateIOParserCtxt
Found by Coverity.

https://bugzilla.redhat.com/show_bug.cgi?id=1938806
2022-01-16 14:14:32 +01:00
David King
f0904f3266 Fix memory leak in xmlParseSGMLCatalog
Found by Coverity.

https://bugzilla.redhat.com/show_bug.cgi?id=1938806
2022-01-16 14:13:26 +01:00
David King
2510f43cba Fix memory leak in xmlParseCatalogFile
Found by Coverity.

https://bugzilla.redhat.com/show_bug.cgi?id=1938806
2022-01-16 14:12:06 +01:00
David King
92bce68c0d Fix memory leak in xmlSAX2AttributeDecl
Found by Coverity.

https://bugzilla.redhat.com/show_bug.cgi?id=1938806
2022-01-16 14:11:28 +01:00
David King
e7d1c53a49 Fix memory leak in xmlFreeParserInputBuffer
Found by Coverity.

https://bugzilla.redhat.com/show_bug.cgi?id=1938806
2022-01-16 14:10:34 +01:00
David Kilzer
03bb929390 Fix parse failure when 4-byte character in UTF-16 BE is split across a chunk
This makes the logic in UTF16BEToUTF8() match UTF16LEToUTF8().

* encoding.c:
(UTF16LEToUTF8):
- Fix comment to describe what the code does.
(UTF16BEToUTF8):
- Fix undefined behavior which was applied to UTF16LEToUTF8() in
  2f9382033e.
- Add bounds check to while() loop which was applied to
  UTF16LEToUTF8() in be803967db.
- Do not return -2 when (in >= inend) to fix the bug.  This was
  applied to UTF16LEToUTF8() in 496a1cf592.
- Inline (<< 8) statements to match UTF16LEToUTF8().

Add the following tests and results:

  test/text-4-byte-UTF-16-BE-offset.xml
  test/text-4-byte-UTF-16-BE.xml
  test/text-4-byte-UTF-16-LE-offset.xml
  test/text-4-byte-UTF-16-LE.xml
2022-01-16 14:07:17 +01:00
Jan Tojnar
e6adc19fff man: Mention XML_CATALOG_FILES is space-separated
Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=781274
2022-01-16 14:03:07 +01:00
Rainer M. Canavan
bdd482c2ec add documentaiton for xmllint exit code 10
Closes: https://gitlab.gnome.org/GNOME/libxml2/-/issues/280
2022-01-16 13:59:57 +01:00
Sam James
a0f9211b52 python/Makefile.am: use *_LIBADD, not *_LDFLAGS for LIBS
This fixes over-linking in the built Python modules with various libraries.

*_LIBADD is intended for adding additional libraries for linking, while
*_LDFLAGS is for miscellaneous extra flags (possibly user-supplied).

If using -Wl,-as-needed within user-supplied LDFLAGS, it is passed too
late (after the library link line) and therefore has no effect.

Notes:

* Noticed while working on Gentoo's migration to libxcrypt because
libxml2's Python modules were linking to libcrypt (and other libraries)
unexpectedly.

* It was suggested we could actually stop linking explicitly with all
of Python's libraries / don't copy its LDFLAGS, but this resolves
the original issue downstream and is a separate discussion. I couldn't
find any clear documentation for/against such a change.

Bug: https://bugs.gentoo.org/798942
Signed-off-by: Sam James <sam@gentoo.org>
2022-01-16 13:58:43 +01:00
Nick Wellnhofer
ff05c94a6e Fix check for libtool in autogen.sh
libtoolize is named glibtoolize on some macOS systems.
2022-01-16 13:58:39 +01:00
Nick Wellnhofer
343bf0d39b Add myself to maintainers
Fixes #319.
2022-01-16 13:52:21 +01:00
Nick Wellnhofer
c35628a24c Revert "Make schema validation fail with multiple top-level elements"
This reverts commit 4f2aee18f6.

Fixes #305.
2022-01-15 18:18:22 +01:00
Nick Wellnhofer
798bdf13f6 Different approach to fix quadratic behavior in HTML push parser
The old approach introduced a regression, see issue #312 and the
previous commit. Disable code that tries to recover from invalid start
tags. This only affects "recovery" mode.

Add a comment outlining a better fix in accordance with the HTML5 spec.
2022-01-10 14:50:20 +01:00
Nick Wellnhofer
094fc08a09 Fix regression when parsing invalid HTML tags in push mode
Revert part of commit 173a0830 that changed behavior when parsing
malformed start tags with the push parser. This reintroduces quadratic
behavior in recovery mode which will be worked around in the next
commit.

Fixes #312.
2022-01-10 14:49:00 +01:00
Nick Wellnhofer
2732b23466 Fix regression parsing public IDs literals in HTML
Fix regression introduced when reworking htmlParsePubidLiteral in
commit 93ce33c2.

Fixes #318.
2022-01-10 13:37:59 +01:00
Nick Wellnhofer
dea91c97de Fix buffering in xmlOutputBufferWrite
Fix a regression introduced with commit a697ed1e which caused
xmlOutputBufferWrite to flush internal buffers too late.

Fixes #296.
2021-07-27 16:12:54 +02:00
Arne Becker
ec6e3efb06 Patch to forbid epsilon-reduction of final states
When building the internal representation of a regexp, it is possible
that a lot of empty transitions are created. Therefore there is a step
to reduce them in the function xmlFAEliminateSimpleEpsilonTransitions.

There is an error there for this case:

* State 1 has a transition with an atom (in this case "a") to state 2.
* State 2 is final and has an epsilon transition to state 1.

After reduction it looked like:
* State 1 has a transition with an atom (in this case "a") to itself
  and is final.

In other words, the empty string is accepted when it shouldn't be.

The attached patch skips the reduction step for final states.
An alternative would be to insert or increment counters when reducing a
final state, but this seemed error prone and unnecessary, since there
aren't that many final states.

Fixes #282
2021-07-06 21:59:25 +02:00