1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-11 04:59:38 +03:00

53 Commits

Author SHA1 Message Date
6a6a46f017 doc: Fix autolink errors
Fix links, remove links to internal functions.
2025-05-28 16:02:41 +02:00
7bd8d1d9cc doc: Prefix autolinks with '#'
Use `#func` instead of `func()` to ignore parameters and make all
autolinks work.
2025-05-28 16:01:52 +02:00
442c1903af doc: Fix some damage from automated conversions
Add some newlines, fix returns.
2025-05-11 20:29:25 +02:00
38ea8fa9de doc: Fix varargs 2025-05-06 19:51:38 +02:00
9bbffec568 doc: Move brief to top, params to bottom of doc comments 2025-05-06 19:51:38 +02:00
e78e05c990 doc: Fix autolinks to functions
Unfortunately, autolinks in .c files aren't converted by Doxygen for
some reason.
2025-05-02 17:45:31 +02:00
e549622bc5 doc: Convert documentation to Doxygen
Automated conversion based on a few regexes.
2025-05-01 23:23:42 +02:00
69879da88f doc: Remove email addresses from documentation
Also remove authorship information from generated files, hash.c and
globals.c which were rewritten.
2025-05-01 23:23:42 +02:00
b7c0f9d2dd string: Fix va_copy fallback
Fix va_copy fallback reworked in 5cffba83.

Should fix #812.
2024-10-19 14:53:25 +02:00
5d36664fc9 memory: Deprecate xmlGcMemSetup 2024-07-16 17:42:10 +02:00
2def7b4b28 clang-tidy: move assignments out of if
Found with bugprone-assignment-in-if-condition

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2024-06-20 21:11:44 -07:00
e75e878e02 doc: Update and fix documentation 2024-05-20 14:23:39 +02:00
650f842dbe string: Don't validate UTF-8 in xmlUTF8Strsub
Most string functions can assume valid UTF-8. In order to detect malloc
failures reliably, xmlUTF8Strsub should only return NULL if the start
index is out of bounds or a memory allocation failed.
2024-04-02 15:34:45 +02:00
aef1ff4372 string: Fix xmlStrncatNew(NULL, "")
This should return "" not NULL.
2024-03-15 19:47:08 +01:00
c5a8aef2f6 error: Refactor error reporting
Introduce xmlStrVASPrintf, trying to handle buggy snprintf
implementations.

Introduce xmlSetError to set errors atomically.

Introduce xmlUpdateError to set an error, fixing up node, file and line.

Introduce helper function xmlRaiseMemoryError.

Make legacy error handlers call xmlReportError, avoiding checks in
xmlVRaiseError.

Remove fragile support for getting file and line info from XInclude
nodes.
2023-12-21 02:46:27 +01:00
2e5d273beb string: Report malloc failures in xmlStrncat
Don't ignore malloc failures silently.
2023-12-11 22:05:47 +01:00
845bd99f8b string: Fix UTF-8 validation in xmlGetUTF8Char 2023-09-29 00:15:40 +02:00
c7260a47f1 malloc-fail: Don't call xmlErrMemory in xmlstring.c
Functions like xmlStrdup are called in the error handling code
(__xmlRaiseError) which can cause problems like use-after-free or
infinite loops when invoked recursively.

Calling xmlErrMemory without a context argument isn't helpful anyway.

Found with libFuzzer, see #344.
2023-01-24 11:47:33 +01:00
dd3569eaa5 Remove XMLDECL macro from .c files 2022-12-08 02:43:17 +01:00
6843fc726f Remove or annotate char casts 2022-09-01 04:31:30 +02:00
2cac626976 Don't use sizeof(xmlChar) or sizeof(char) 2022-09-01 03:35:19 +02:00
0f568c0b73 Consolidate private header files
Private functions were previously declared

- in header files in the root directory
- in public headers guarded with IN_LIBXML
- in libxml.h
- redundantly in source files that used them.

Consolidate all private header files in include/private.
2022-08-26 02:11:56 +02:00
48ed5a74bd Update xmlStrlen() to use POSIX / ISO C strlen()
This should be faster on a wide range of platforms.

Closes #212
2022-02-26 16:20:32 +00:00
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
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
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
9de7b94d4f Use strcmp when fuzzing
This should improve data-flow-guided fuzzing.
2020-08-08 20:37:30 +02:00
5a0ae66d72 Documentation fixes
Fixes bug 347465, bug 599433, bug 624550, bug 698253.
2017-06-18 17:58:38 +02:00
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
502f6a6d08 More format string warnings with possible format string vulnerability
For https://bugzilla.gnome.org/show_bug.cgi?id=761029

adds a new xmlEscapeFormatString() function to escape composed format
strings
2016-05-23 15:01:08 +08:00
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
8fbbf5513d Bug 763071: heap-buffer-overflow in xmlStrncat <https://bugzilla.gnome.org/show_bug.cgi?id=763071>
* xmlstring.c:
(xmlStrncat): Return NULL if xmlStrlen returns a negative length.
(xmlStrncatNew): Ditto.
2016-05-22 09:33:57 +08:00
96a5c17ee1 Fix OOB read with invalid UTF-8 in xmlUTF8Strsize
With certain invalid UTF-8, xmlUTF8Strsize can read up to 6 bytes
beyond the end of the string and return the wrong size.

This means that in xmlUTF8Strndup and similar code, some content behind
the string is copied. But since the terminating \0 is copied as well,
this probably can't be exploited to leak sensitive information.

Found by afl-fuzz and ASan.
2016-04-23 18:44:27 +02:00
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
fcf2457d20 Both args of xmlStrcasestr are const
* include/libxml/xmlstring.h xmlstring.c: fix the constness of the
  second arg of xmlStrcasestr()
2009-08-12 23:02:08 +02:00
d95ecf0b8d Fixed xmlStrEqual() doc, Daniel 2005-12-22 14:58:32 +00:00
5bb0c08d2f Fixed a segfault during text concatenation when validating a node tree:
* xmlschemas.c xmlstring.c: Fixed a segfault during
  text concatenation when validating a node tree:
  xmlStrncat was called with a @len of -1; but unlike
  xmlStrncatNew, it does not calculate the length
  automatically in such a case (reported by Judy Hay
  on the mailing list).
  Updated the descriptions of the involved string
  functions to note this.
2005-12-20 10:48:33 +00:00
6a0baa0cd8 fixed a number of warnings shown by HP-UX compiler and reported by Rick
* HTMLparser.c configure.in parserInternals.c runsuite.c runtest.c
  testapi.c xmlschemas.c xmlschemastypes.c xmlstring.c: fixed a number
  of warnings shown by HP-UX compiler and reported by Rick Jones
Daniel
2005-12-10 11:11:12 +00:00
ffa3c74933 applied a patch from Marcus Boerger to fix problems with calling
* error.c globals.c parser.c runtest.c testHTML.c testSAX.c
  threads.c valid.c xmllint.c xmlreader.c xmlschemas.c xmlstring.c
  xmlwriter.c include/libxml/parser.h include/libxml/relaxng.h
  include/libxml/valid.h include/libxml/xmlIO.h
  include/libxml/xmlerror.h include/libxml/xmlexports.h
  include/libxml/xmlschemas.h: applied a patch from Marcus Boerger
  to fix problems with calling conventions on Windows this should
  fix #309757
Daniel
2005-07-21 13:24:09 +00:00
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
230c5504d1 reset input->base within xmlStopParser removed call to xmlUTF8Strlen from
* parser.c: reset input->base within xmlStopParser
* xmlstring.c: removed call to xmlUTF8Strlen from within
  xmlUTF8Strpos (Bill Moseley pointed out it was not
  useful)
2004-12-20 16:18:49 +00:00
5ea30d7f95 more fixes. Daniel
* parser.c testapi.c xmlIO.c xmlstring.c: more fixes.
Daniel
2004-11-08 11:54:28 +00:00
ce682bc24b autogenerate a minimal NULL value sequence for unknown pointer types This
* gentest.py testapi.c: autogenerate a minimal NULL value sequence
  for unknown pointer types
* HTMLparser.c SAX2.c chvalid.c encoding.c entities.c parser.c
  parserInternals.c relaxng.c valid.c xmlIO.c xmlreader.c
  xmlsave.c xmlschemas.c xmlschemastypes.c xmlstring.c xpath.c
  xpointer.c: This uncovered an impressive amount of entry points
  not checking for NULL pointers when they ought to, closing all
  the open gaps.
Daniel
2004-11-05 17:22:25 +00:00
8a32fe4839 more testing and coverage more cleanups rebuilt Daniel
* gentest.py testapi.c: more testing and coverage
* elfgcchack.h xmlstring.c include/libxml/xmlstring.h: more cleanups
* doc/*: rebuilt
Daniel
2004-11-02 22:10:16 +00:00
36e5cd5064 adding xmlMemBlocks() work on generator of an automatic API regression
* xmlmemory.c include/libxml/xmlmemory.h: adding xmlMemBlocks()
* Makefile.am gentest.py testapi.c: work on generator of an
  automatic API regression test tool.
* SAX2.c nanoftp.c parser.c parserInternals.c tree.c xmlIO.c
  xmlstring.c: various API hardeing changes as a result of running
  teh first set of automatic API regression tests.
* test/slashdot16.xml: apparently missing from CVS, commited it
Daniel
2004-11-02 14:52:23 +00:00
b7b54de6c6 added code to handle <group>, including dumping to output (bug 151924).
* catalog.c: added code to handle <group>, including dumping
  to output (bug 151924).
* xmlcatalog.c, xmlstring.c, parser.c: minor compiler warning
  cleanup (no change to logic)
2004-10-06 16:38:01 +00:00
3e53016965 modified comments on xmlGetUTF8Char in response to bug 151760 (no change
* xmlstring.c: modified comments on xmlGetUTF8Char in
  response to bug 151760 (no change to logic)
2004-09-03 17:10:08 +00:00
f409515f15 fixed error reported on the list caused by my last change
* xmlstring.c: fixed error reported on the list caused by
  my last change
2004-08-31 16:49:26 +00:00
bf5cf2196c fixed bug introduced during OOM fixup causing problems with default
* SAX2.c: fixed bug introduced during OOM fixup causing problems
  with default namespace when a named prefix with the same href
  was present (reported on the mailing list by Karl Eichwalder.
* xmlstring.c: modified xmlCheckUTF8 with suggested code from
  Julius Mittenzwei.
* dict.c: added a typecast to try to avoid problem reported by
  Pascal Rodes.
2004-08-31 06:47:17 +00:00
3ffe90ea1c fixed a problem with xmlCheckUTF8 reported on the mailing list by Julius
* xmlstring.c: fixed a problem with xmlCheckUTF8 reported on the
  mailing list by Julius Mittenzwei
2004-08-28 01:33:30 +00:00