1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2026-01-28 10:01:00 +03:00
Commit Graph

5160 Commits

Author SHA1 Message Date
Nick Wellnhofer
2017cae6df Upload documentation to GitLab pages 2022-02-12 20:04:48 +01:00
Nick Wellnhofer
be889b6581 Make xmlFuzzReadString return a zero size in error case
Avoids use of uninitialized memory.
2022-02-12 15:54:54 +01:00
Nick Wellnhofer
57b3abd592 Fix xmlSetTreeDoc with entity references
The children member of entity reference nodes points to the entity
declaration and must never be followed when traversing a tree. In
the worst case, this could lead to an infinite loop.

It's somewhat unclear how moving entity references to other documents
should work exactly. For now we simply set the children pointer to NULL
to avoid a reference to the original document.

Fixes #42.
2022-02-07 22:18:27 +01:00
Nick Wellnhofer
8be44aeb16 Fix "xmllint -"
Short-lived regression from commit d12be00d.
2022-02-07 20:54:33 +01:00
Nick Wellnhofer
9edc20c154 Fix double counting of CRLF in comments
Fixes #151.
2022-02-07 20:54:07 +01:00
Nick Wellnhofer
b14649e397 Remove old ChangeLog
This was probably generated from SVN until 2009. Changes are now
tracked in NEWS.

Fixes #261.
2022-02-07 19:54:20 +01:00
Nick Wellnhofer
fcd4c5b824 Document how to escape XML_CATALOG_FILES
Fixes #309.
2022-02-07 19:22:45 +01:00
Nick Wellnhofer
ea53fc18bc Properly handle nested documents in xmlFreeNode
Client code should never add document nodes as children of other nodes,
but even our own XPointer code has a bug that can produce such trees.
Make sure to really free nested documents. Also see commits 0815302d
and 0762c9b6.

Should fix #269.
2022-02-07 18:36:00 +01:00
Nick Wellnhofer
9653565765 Make sure to grow input buffer in xmlParseMisc
Otherwise, large amount of whitespace could lead to documents not
being parsed correctly.

Fixes #299.
2022-02-07 15:43:36 +01:00
Nick Wellnhofer
9b8ef34dc9 Fix unused function warning in testapi.c 2022-02-04 14:42:16 +01:00
Nick Wellnhofer
d12be00da8 Don't ignore xmllint options after "-"
There's no reason to ignore options after "-". This was probably
confused with the "--" mechanism which xmllint doesn't implement.

Fixes #290.
2022-02-04 14:13:59 +01:00
Nick Wellnhofer
5408c10c37 Don't normalize namespace URIs in XPointer xmlns() scheme
Namespace URIs should be compared without escaping or unescaping:

https://www.w3.org/TR/REC-xml-names/#NSNameComparison

Fixes #289.
2022-02-04 14:00:09 +01:00
Nick Wellnhofer
1c7d91abe4 Fix handling of XSD with empty namespace
An empty namespace means no default namespace.

Fixes #303.
2022-02-03 23:31:19 +01:00
Nick Wellnhofer
f480f7509c Update NewsML DTD in test suite
Switch to version 1.2 which has a clearer license.

Fixes #291.
2022-02-03 14:43:17 +01:00
Nick Wellnhofer
247cfa27cc Fix parsing of xmllint --maxmem option
Fixes #195.
2022-02-01 16:38:29 +01:00
Nick Wellnhofer
96dc7f4ae6 Also register HTML document nodes
Fixes #196.
2022-02-01 16:38:29 +01:00
Nick Wellnhofer
18d1f9d42a Add more checks for malloc failures in xmllint.c
Also fix a few of the existing checks.

Fixes #197.
Fixes #198.
2022-02-01 16:38:17 +01:00
Nick Wellnhofer
eab8652216 Make xmllint return an error if arguments are missing
Before, xmllint would only return an error code if the argument
list was completely empty.

Fixes #285.
2022-01-31 14:45:09 +01:00
Nick Wellnhofer
6010a5369f Avoid potential integer overflow in xmlstring.c
For historical reasons, the string API operates with int indices which
can overflow, especially on 64-bit systems. libxml2 always made the
tacit assumption that strings will be never larger than INT_MAX bytes.
It should be considered a bug if any part of the code can produce
larger strings, whether they are externally visible or not.

Likewise, API users are expected not to supply strings larger than
INT_MAX bytes. This requirement isn't documented. But even if it was,
we must handle larger strings passed in by accident without causing
memory errors.

- xmlStrndup, xmlCharStrndup, xmlUTF8Strndup
  Avoid integer overflow if len == INT_MAX.

- xmlStrlen, xmlUTF8Strsize, xmlUTF8Strloc
  Avoid integer overflow by using size_t for index. If an input string
  larger than INT_MAX bytes is detected, these functions now return 0
  instead of a wrong and possibly negative value.

- xmlCheckUTF8
  Avoid integer overflow by limiting index range.

- xmlStrncat, xmlStrncatNew, xmlEscapeFormatString
  Avoid integer overflow. Return NULL instead of producing strings
  larger than INT_MAX bytes.
2022-01-28 16:27:12 +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
53983804ce Run CI tests with UBSan implicit-conversion checks
This enables the remaining checks from the "integer" group:

- implicit-unsigned-integer-truncation
- implicit-signed-integer-truncation
- implicit-integer-sign-change

These checks can find all kinds of bugs and only require explicit casts
if integer truncation or sign change is really intended.
2022-01-25 03:20:28 +01:00
Nick Wellnhofer
a647e43025 Fix casting of line numbers in SAX2.c
The line member is an unsigned short. Avoids integer conversion warnings
with UBSan.

Also use USHRT_MAX instead of hard-coded constant.
2022-01-25 03:20:28 +01:00
Nick Wellnhofer
67c2e78b81 Fix integer conversion warnings in hash.c
Use unsigned long for temporary variable to avoid integer conversion
warnings with UBSan.

Note that this does change the computation of hash values for input
bytes larger than 0x7F. Before, these bytes were first converted to a
(typically) signed char with a negative value, then to a large unsigned
long near ULONG_MAX. I doubt that this was intentional. Input bytes
larger than 0x7F are now converted to unsigned long unchanged.
2022-01-25 03:15:12 +01:00
Nick Wellnhofer
21217dd94c Add explicit casts in runtest.c
Avoids integer conversion warnings with UBSan.
2022-01-25 03:07:30 +01:00
Nick Wellnhofer
7abc6e6a24 Fix integer conversion warning in xmlIconvWrapper
Use size_t for return value of iconv(3) to avoid an UBSan integer
conversion warning.
2022-01-25 03:07:30 +01:00
Nick Wellnhofer
f4a74bf0ae Add suffix to unsigned constant in xmlmemory.c
Avoids an integer conversion warning with UBSan.
2022-01-25 03:07:30 +01:00
Nick Wellnhofer
5948abfe99 Add explicit casts in testchar.c
Avoids integer conversion warnings with UBSan.
2022-01-25 01:59:03 +01:00
Nick Wellnhofer
6f95273e44 Fix integer conversion warnings in xmlstring.c
Use an int to avoid an integer conversion warning with UBSan when
left-shifting a char.
2022-01-25 01:53:43 +01:00
Nick Wellnhofer
0596d67ddc Add explicit cast in xmlURIUnescapeString
Avoids an integer conversion warning with UBSan.
2022-01-25 01:39:41 +01:00
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