From 08819b4170fcd59bf2520ff6a2d2af47b8c56234 Mon Sep 17 00:00:00 2001 From: bluhm Date: Wed, 26 May 2021 19:14:32 +0000 Subject: [PATCH] Update libexpat to 2.4.1. This fixes CVE-2013-0340. Relevant for OpenBSD are security fixes #34 #466 #484 and other changes #467 #473 #483. A new error number in a public header requires a major library bump. Two functions have been added to API. OK tb@ --- lib/libexpat/Changes | 91 ++ lib/libexpat/Makefile | 4 +- lib/libexpat/README.md | 41 +- lib/libexpat/doc/reference.html | 380 +++++-- lib/libexpat/doc/style.css | 134 +-- lib/libexpat/examples/elements.c | 7 +- lib/libexpat/examples/outline.c | 8 +- lib/libexpat/lib/ascii.h | 7 +- lib/libexpat/lib/asciitab.h | 4 +- lib/libexpat/lib/expat.h | 34 +- lib/libexpat/lib/expat_external.h | 9 +- lib/libexpat/lib/iasciitab.h | 4 +- lib/libexpat/lib/internal.h | 55 +- lib/libexpat/lib/latin1tab.h | 4 +- lib/libexpat/lib/nametab.h | 4 +- lib/libexpat/lib/utf8tab.h | 4 +- lib/libexpat/lib/winconfig.h | 19 +- lib/libexpat/lib/xmlparse.c | 1195 ++++++++++++++++++++-- lib/libexpat/lib/xmlrole.c | 17 +- lib/libexpat/lib/xmlrole.h | 5 +- lib/libexpat/lib/xmltok.c | 32 +- lib/libexpat/lib/xmltok.h | 6 +- lib/libexpat/lib/xmltok_impl.c | 14 +- lib/libexpat/lib/xmltok_impl.h | 3 +- lib/libexpat/lib/xmltok_ns.c | 6 +- lib/libexpat/shlib_version | 2 +- lib/libexpat/tests/benchmark/benchmark.c | 6 +- lib/libexpat/tests/chardata.c | 12 +- lib/libexpat/tests/chardata.h | 5 +- lib/libexpat/tests/memcheck.c | 4 +- lib/libexpat/tests/memcheck.h | 4 +- lib/libexpat/tests/minicheck.c | 7 +- lib/libexpat/tests/minicheck.h | 5 +- lib/libexpat/tests/runtests.c | 429 +++++++- lib/libexpat/tests/runtestspp.cpp | 4 +- lib/libexpat/tests/structdata.c | 8 +- lib/libexpat/tests/structdata.h | 3 +- lib/libexpat/tests/xmltest.sh | 43 +- 38 files changed, 2242 insertions(+), 377 deletions(-) diff --git a/lib/libexpat/Changes b/lib/libexpat/Changes index edd485c8dd0..f765789857e 100644 --- a/lib/libexpat/Changes +++ b/lib/libexpat/Changes @@ -2,6 +2,97 @@ NOTE: We are looking for help with a few things: https://github.com/libexpat/libexpat/labels/help%20wanted If you can help, please get in touch. Thanks! +Release 2.4.1 Sun May 23 2021 + Bug fixes: + #488 #490 Autotools: Fix installed header expat_config.h for multilib + systems; regression introduced in 2.4.0 by pull request #486 + + Other changes: + #491 #492 Version info bumped from 9:0:8 to 9:1:8; + see https://verbump.de/ for what these numbers do + + Special thanks to: + Gentoo's QA check "multilib_check_headers" + +Release 2.4.0 Sun May 23 2021 + Security fixes: + #34 #466 #484 CVE-2013-0340/CWE-776 -- Protect against billion laughs attacks + (denial-of-service; flavors targeting CPU time or RAM or both, + leveraging general entities or parameter entities or both) + by tracking and limiting the input amplification factor + ( := ( + ) / ). + By conservative default, amplification up to a factor of 100.0 + is tolerated and rejection only starts after 8 MiB of output bytes + (= + ) have been processed. + The fix adds the following to the API: + - A new error code XML_ERROR_AMPLIFICATION_LIMIT_BREACH to + signals this specific condition. + - Two new API functions .. + - XML_SetBillionLaughsAttackProtectionMaximumAmplification and + - XML_SetBillionLaughsAttackProtectionActivationThreshold + .. to further tighten billion laughs protection parameters + when desired. Please see file "doc/reference.html" for details. + If you ever need to increase the defaults for non-attack XML + payload, please file a bug report with libexpat. + - Two new XML_FEATURE_* constants .. + - that can be queried using the XML_GetFeatureList function, and + - that are shown in "xmlwf -v" output. + - Two new environment variable switches .. + - EXPAT_ACCOUNTING_DEBUG=(0|1|2|3) and + - EXPAT_ENTITY_DEBUG=(0|1) + .. for runtime debugging of accounting and entity processing. + Specific behavior of these values may change in the future. + - Two new command line arguments "-a FACTOR" and "-b BYTES" + for xmlwf to further tighten billion laughs protection + parameters when desired. + If you ever need to increase the defaults for non-attack XML + payload, please file a bug report with libexpat. + + Bug fixes: + #332 #470 For (non-default) compilation with -DEXPAT_MIN_SIZE=ON (CMake) + or CPPFLAGS=-DXML_MIN_SIZE (GNU Autotools): Fix segfault + for UTF-16 payloads containing CDATA sections. + #485 #486 Autotools: Fix generated CMake files for non-64bit and + non-Linux platforms (e.g. macOS and MinGW in particular) + that were introduced with release 2.3.0 + + Other changes: + #468 #469 xmlwf: Improve help output and the xmlwf man page + #463 xmlwf: Improve maintainability through some refactoring + #477 xmlwf: Fix man page DocBook validity + #458 #459 CMake: Support absolute paths for both CMAKE_INSTALL_LIBDIR + and CMAKE_INSTALL_INCLUDEDIR + #471 #481 CMake: Add support for standard variable BUILD_SHARED_LIBS + #457 Unexpose symbol _INTERNAL_trim_to_complete_utf8_characters + #467 Resolve macro HAVE_EXPAT_CONFIG_H + #472 Delete unused legacy helper file "conftools/PrintPath" + #473 #483 Improve attribution + #464 #465 #477 doc/reference.html: Fix XHTML validity + #475 #478 doc/reference.html: Replace the 90s look by OK.css + #479 Version info bumped from 8:0:7 to 9:0:8 + due to addition of new symbols and error codes; + see https://verbump.de/ for what these numbers do + + Infrastructure: + #456 CI: Enable periodic runs + #457 CI: Start covering the list of exported symbols + #474 CI: Isolate coverage task + #476 #482 CI: Adapt to breaking changes in image "ubuntu-18.04" + #477 CI: Cover well-formedness and DocBook/XHTML validity + of doc/reference.html and doc/xmlwf.xml + + Special thanks to: + Dimitry Andric + Eero Helenius + Nick Wellnhofer + Rhodri James + Tomas Korbar + Yury Gribov + and + Clang LeakSan + JetBrains + OSS-Fuzz + Release 2.3.0 Thu March 25 2021 Bug fixes: #438 When calling XML_ParseBuffer without a prior successful call to diff --git a/lib/libexpat/Makefile b/lib/libexpat/Makefile index 8bb75e7408c..25b03847b2c 100644 --- a/lib/libexpat/Makefile +++ b/lib/libexpat/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.15 2019/06/29 00:33:59 bluhm Exp $ +# $OpenBSD: Makefile,v 1.16 2021/05/26 19:14:32 bluhm Exp $ .PATH: ${.CURDIR}/lib @@ -6,7 +6,7 @@ LIB= expat SRCS= xmlparse.c xmltok.c xmlrole.c -CFLAGS+=-I${.CURDIR} -DHAVE_EXPAT_CONFIG_H +CFLAGS+=-I${.CURDIR} .if ${COMPILER_VERSION:L} != "gcc3" CFLAGS+=-fvisibility=hidden -DXML_ENABLE_VISIBILITY=1 .endif diff --git a/lib/libexpat/README.md b/lib/libexpat/README.md index 6e4b422673a..251dc8a19b3 100644 --- a/lib/libexpat/README.md +++ b/lib/libexpat/README.md @@ -1,12 +1,14 @@ [![Run Linux Travis CI tasks](https://github.com/libexpat/libexpat/actions/workflows/linux.yml/badge.svg)](https://github.com/libexpat/libexpat/actions/workflows/linux.yml) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/libexpat/libexpat?svg=true)](https://ci.appveyor.com/project/libexpat/libexpat) [![Packaging status](https://repology.org/badge/tiny-repos/expat.svg)](https://repology.org/metapackage/expat/versions) +[![Downloads SourceForge](https://img.shields.io/sourceforge/dt/expat?label=Downloads%20SourceForge)](https://sourceforge.net/projects/expat/files/) +[![Downloads GitHub](https://img.shields.io/github/downloads/libexpat/libexpat/total?label=Downloads%20GitHub)](https://github.com/libexpat/libexpat/releases) -# Expat, Release 2.3.0 +# Expat, Release 2.4.1 This is Expat, a C library for parsing XML, started by -[James Clark](https://en.wikipedia.org/wiki/James_Clark_(programmer)) in 1997. +[James Clark](https://en.wikipedia.org/wiki/James_Clark_%28programmer%29) in 1997. Expat is a stream-oriented XML parser. This means that you register handlers with the parser before starting the parse. These handlers are called when the parser discovers the associated structures in the @@ -20,7 +22,7 @@ Expat supports the following compilers: - Microsoft Visual Studio >=15.0/2017 (rolling `${today} minus 5 years`) Windows users can use the -[`expat-win32bin-*.*.*.exe` installer download](https://github.com/libexpat/libexpat/releases), +[`expat-win32bin-*.*.*.{exe,zip}` download](https://github.com/libexpat/libexpat/releases), which includes both pre-compiled libraries and executables, and source code for developers. @@ -40,10 +42,10 @@ There are two ways of using libexpat with CMake: This approach leverages CMake's own [module `FindEXPAT`](https://cmake.org/cmake/help/latest/module/FindEXPAT.html). -Notice the uppercase `EXPAT` in the following example: +Notice the *uppercase* `EXPAT` in the following example: ```cmake -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.0) # or 3.10, see below project(hello VERSION 1.0.0) @@ -53,22 +55,27 @@ add_executable(hello hello.c ) -if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.10") - target_link_libraries(hello PUBLIC EXPAT::EXPAT) -else() - target_include_directories(hello PRIVATE ${EXPAT_INCLUDE_DIRS}) - target_link_libraries(hello PUBLIC ${EXPAT_LIBRARIES}) -endif() +# a) for CMake >=3.10 (see CMake's FindEXPAT docs) +target_link_libraries(hello PUBLIC EXPAT::EXPAT) + +# b) for CMake >=3.0 +target_include_directories(hello PRIVATE ${EXPAT_INCLUDE_DIRS}) +target_link_libraries(hello PUBLIC ${EXPAT_LIBRARIES}) ``` ### b) Config Mode -This approach requires files from -libexpat >=2.2.8 where packaging uses the CMake build system +This approach requires files from… + +- libexpat >=2.2.8 where packaging uses the CMake build system +or +- libexpat >=2.3.0 where packaging uses the GNU Autotools build system + on Linux or -libexpat >=2.3.0 where packaging uses the GNU Autotools build system. +- libexpat >=2.4.0 where packaging uses the GNU Autotools build system + on macOS or MinGW. -Notice the lowercase `expat` in the following example: +Notice the *lowercase* `expat` in the following example: ```cmake cmake_minimum_required(VERSION 3.0) @@ -85,7 +92,7 @@ target_link_libraries(hello PUBLIC expat::expat) ``` -## Buildung from a Git Clone +## Building from a Git Clone If you are building Expat from a check-out from the [Git repository](https://github.com/libexpat/libexpat/), @@ -101,7 +108,7 @@ Once this has been done, follow the same instructions as for building from a source distribution. -## Buildung from a Source Distribution +## Building from a Source Distribution ### a) Building with the configure script (i.e. GNU Autotools) diff --git a/lib/libexpat/doc/reference.html b/lib/libexpat/doc/reference.html index 1e4780ed70c..309cb2415bb 100644 --- a/lib/libexpat/doc/reference.html +++ b/lib/libexpat/doc/reference.html @@ -3,26 +3,54 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Expat XML Parser + - - - - - - - - - -
(Expat logo)
Release 2.0.1
+
+

+ The Expat XML Parser + Release 2.4.1 +

+

Expat is a library, written in C, for parsing XML documents. It's @@ -120,6 +148,13 @@ interface.

  • XML_GetInputContext
  • +
  • + Billion Laughs Attack Protection + +
  • Miscellaneous Functions
    • XML_SetUserData
    • @@ -900,7 +935,8 @@ whether the parse can be resumed in the future.

      Parser Creation

      -
      +

      XML_ParserCreate

      +
       XML_Parser XMLCALL
       XML_ParserCreate(const XML_Char *encoding);
       
      @@ -917,7 +953,8 @@ encoding declaration. There are four built-in encodings: Any other value will invoke a call to the UnknownEncodingHandler.
  • -
    +

    XML_ParserCreateNS

    +
     XML_Parser XMLCALL
     XML_ParserCreateNS(const XML_Char *encoding,
                        XML_Char sep);
    @@ -936,7 +973,8 @@ the local part will be concatenated without any separator - this is intended
     to support RDF processors. It is a programming error to use the null separator
     with namespace triplets.
     
    -
    +

    XML_ParserCreate_MM

    +
     XML_Parser XMLCALL
     XML_ParserCreate_MM(const XML_Char *encoding,
                         const XML_Memory_Handling_Suite *ms,
    @@ -958,7 +996,8 @@ and the character pointed at by sep is used as the separator between
     the namespace URI and the local part of the name.

    -
    +

    XML_ExternalEntityParserCreate

    +
     XML_Parser XMLCALL
     XML_ExternalEntityParserCreate(XML_Parser p,
                                    const XML_Char *context,
    @@ -974,7 +1013,8 @@ changing functions on this parser (unless you want it to act
     differently than the parent parser).
     
     
    -
    +

    XML_ParserFree

    +
     void XMLCALL
     XML_ParserFree(XML_Parser p);
     
    @@ -983,7 +1023,8 @@ Free memory used by the parser. Your application is responsible for freeing any memory associated with user data. -
    +

    XML_ParserReset

    +
     XML_Bool XMLCALL
     XML_ParserReset(XML_Parser p,
                     const XML_Char *encoding);
    @@ -1014,7 +1055,7 @@ if they apply to the parser created by
     XML_ExternalEntityParserCreate.

    -

    Note: the len argument passed to these functions +

    Note: The len argument passed to these functions should be considerably less than the maximum value for an integer, as it could create an integer overflow situation if the added lengths of a buffer and the unprocessed portion of the previous buffer @@ -1022,7 +1063,8 @@ exceed the maximum integer value. Input data at the end of a buffer will remain unprocessed if it is part of an XML token for which the end is not part of that buffer.

    -
    +

    XML_Parse

    +
     enum XML_Status XMLCALL
     XML_Parse(XML_Parser p,
               const char *s,
    @@ -1049,7 +1091,8 @@ If a parse error occurred, it returns XML_STATUS_ERROR.
     Otherwise it returns XML_STATUS_OK value.
     
     
    -
    +

    XML_ParseBuffer

    +
     enum XML_Status XMLCALL
     XML_ParseBuffer(XML_Parser p,
                     int len,
    @@ -1063,7 +1106,8 @@ buffer from Expat with the 
     
    -
    +

    XML_GetBuffer

    +
     void * XMLCALL
     XML_GetBuffer(XML_Parser p,
                   int len);
    @@ -1098,7 +1142,8 @@ for (;;) {
     
    -
    +

    XML_StopParser

    +
     enum XML_Status XMLCALL
     XML_StopParser(XML_Parser p,
                    XML_Bool resumable);
    @@ -1111,7 +1156,7 @@ XML_StopParser(XML_Parser p,
     call-back handler, except when aborting (when resumable
     is XML_FALSE) an already suspended parser.  Some
     call-backs may still follow because they would otherwise get
    -lost, including
    +lost, including

    • the end element handler for empty elements when stopped in the start element handler,
    • @@ -1120,7 +1165,7 @@ lost, including
    • the character data handler when stopped in the character data handler while making multiple call-backs on a contiguous chunk of characters,
    -and possibly others.

    +

    and possibly others.

    This can be called from most handlers, including DTD related call-backs, except when parsing an external parameter entity and @@ -1166,7 +1211,8 @@ implementation of that handler to call New in Expat 1.95.8.

    -
    +

    XML_ResumeParser

    +
     enum XML_Status XMLCALL
     XML_ResumeParser(XML_Parser p);
     
    @@ -1191,7 +1237,8 @@ appropriate moment.

    New in Expat 1.95.8.

    -
    +

    XML_GetParsingStatus

    +
     void XMLCALL
     XML_GetParsingStatus(XML_Parser p,
                          XML_ParsingStatus *status);
    @@ -1240,7 +1287,8 @@ Note that you'll receive them in this form independent of the original
     encoding of the document.

    -
    +

    XML_SetStartElementHandler

    +
     void XMLCALL
     XML_SetStartElementHandler(XML_Parser p,
                                XML_StartElementHandler start);
    @@ -1261,7 +1309,8 @@ by a null pointer.

    -
    +

    XML_SetEndElementHandler

    +
     void XMLCALL
     XML_SetEndElementHandler(XML_Parser p,
                              XML_EndElementHandler);
    @@ -1276,7 +1325,8 @@ generates a call to both start and end handlers.

    -
    +

    XML_SetElementHandler

    +
     void XMLCALL
     XML_SetElementHandler(XML_Parser p,
                           XML_StartElementHandler start,
    @@ -1286,7 +1336,8 @@ XML_SetElementHandler(XML_Parser p,
     
    -
    +

    XML_SetCharacterDataHandler

    +
     void XMLCALL
     XML_SetCharacterDataHandler(XML_Parser p,
                                 XML_CharacterDataHandler charhndl)
    @@ -1309,7 +1360,8 @@ will continue calling back until the end of the block is reached.

    -
    +

    XML_SetProcessingInstructionHandler

    +
     void XMLCALL
     XML_SetProcessingInstructionHandler(XML_Parser p,
                                         XML_ProcessingInstructionHandler proc)
    @@ -1327,7 +1379,8 @@ it after skipping all whitespace after the initial word.

    -
    +

    XML_SetCommentHandler

    +
     void XMLCALL
     XML_SetCommentHandler(XML_Parser p,
                           XML_CommentHandler cmnt)
    @@ -1342,7 +1395,8 @@ delimiters.

    -
    +

    XML_SetStartCdataSectionHandler

    +
     void XMLCALL
     XML_SetStartCdataSectionHandler(XML_Parser p,
                                     XML_StartCdataSectionHandler start);
    @@ -1355,7 +1409,8 @@ typedef void
     
    -
    +

    XML_SetEndCdataSectionHandler

    +
     void XMLCALL
     XML_SetEndCdataSectionHandler(XML_Parser p,
                                   XML_EndCdataSectionHandler end);
    @@ -1368,7 +1423,8 @@ typedef void
     
    -
    +

    XML_SetCdataSectionHandler

    +
     void XMLCALL
     XML_SetCdataSectionHandler(XML_Parser p,
                                XML_StartCdataSectionHandler start,
    @@ -1378,7 +1434,8 @@ XML_SetCdataSectionHandler(XML_Parser p,
     
    -
    +

    XML_SetDefaultHandlerExpand

    +
     void XMLCALL
     XML_SetDefaultHandlerExpand(XML_Parser p,
                                 XML_DefaultHandler hndl)
    @@ -1429,7 +1487,8 @@ href="#XML_DefaultCurrent">XML_DefaultCurrent.

    -
    +

    XML_SetExternalEntityRefHandler

    +
     void XMLCALL
     XML_SetExternalEntityRefHandler(XML_Parser p,
                                     XML_ExternalEntityRefHandler hndl)
    @@ -1482,7 +1541,8 @@ parser, the body of the external entity can be recursively parsed.

    information into global or static variables.

    -
    +

    XML_SetExternalEntityRefHandlerArg

    +
     void XMLCALL
     XML_SetExternalEntityRefHandlerArg(XML_Parser p,
                                        void *arg)
    @@ -1508,7 +1568,8 @@ properly.

    -
    +

    XML_SetSkippedEntityHandler

    +
     void XMLCALL
     XML_SetSkippedEntityHandler(XML_Parser p,
                                 XML_SkippedEntityHandler handler)
    @@ -1528,14 +1589,15 @@ typedef void
     	   has been called.
     
     

    The is_parameter_entity argument will be non-zero for -a parameter entity and zero for a general entity.

    Note: skipped +a parameter entity and zero for a general entity.

    Note: Skipped parameter entities in declarations and skipped general entities in attribute values cannot be reported, because the event would be out of sync with the reporting of the declarations or attribute values

    -
    +

    XML_SetUnknownEncodingHandler

    +
     void XMLCALL
     XML_SetUnknownEncodingHandler(XML_Parser p,
                                   XML_UnknownEncodingHandler enchandler,
    @@ -1584,7 +1646,8 @@ parser when it is finished with the encoding. It may be NULL.

    -
    +

    XML_SetStartNamespaceDeclHandler

    +
     void XMLCALL
     XML_SetStartNamespaceDeclHandler(XML_Parser p,
     			         XML_StartNamespaceDeclHandler start);
    @@ -1602,7 +1665,8 @@ in that start tag.

    -
    +

    XML_SetEndNamespaceDeclHandler

    +
     void XMLCALL
     XML_SetEndNamespaceDeclHandler(XML_Parser p,
     			       XML_EndNamespaceDeclHandler end);
    @@ -1619,7 +1683,8 @@ namespace was declared.

    -
    +

    XML_SetNamespaceDeclHandler

    +
     void XMLCALL
     XML_SetNamespaceDeclHandler(XML_Parser p,
                                 XML_StartNamespaceDeclHandler start,
    @@ -1629,7 +1694,8 @@ XML_SetNamespaceDeclHandler(XML_Parser p,
     
    -
    +

    XML_SetXmlDeclHandler

    +
     void XMLCALL
     XML_SetXmlDeclHandler(XML_Parser p,
     		      XML_XmlDeclHandler xmldecl);
    @@ -1652,7 +1718,8 @@ that it was given as yes.

    -
    +

    XML_SetStartDoctypeDeclHandler

    +
     void XMLCALL
     XML_SetStartDoctypeDeclHandler(XML_Parser p,
     			       XML_StartDoctypeDeclHandler start);
    @@ -1672,7 +1739,8 @@ will be non-zero if the DOCTYPE declaration has an internal subset.

    -
    +

    XML_SetEndDoctypeDeclHandler

    +
     void XMLCALL
     XML_SetEndDoctypeDeclHandler(XML_Parser p,
     			     XML_EndDoctypeDeclHandler end);
    @@ -1686,7 +1754,8 @@ after parsing any external subset.

    -
    +

    XML_SetDoctypeDeclHandler

    +
     void XMLCALL
     XML_SetDoctypeDeclHandler(XML_Parser p,
     			  XML_StartDoctypeDeclHandler start,
    @@ -1696,7 +1765,8 @@ XML_SetDoctypeDeclHandler(XML_Parser p,
     
    -
    +

    XML_SetElementDeclHandler

    +
     void XMLCALL
     XML_SetElementDeclHandler(XML_Parser p,
     			  XML_ElementDeclHandler eldecl);
    @@ -1768,7 +1838,8 @@ or sequence and children points to the nodes.

    -
    +

    XML_SetAttlistDeclHandler

    +
     void XMLCALL
     XML_SetAttlistDeclHandler(XML_Parser p,
                               XML_AttlistDeclHandler attdecl);
    @@ -1801,7 +1872,8 @@ in the dflt parameter.

    -
    +

    XML_SetEntityDeclHandler

    +
     void XMLCALL
     XML_SetEntityDeclHandler(XML_Parser p,
     			 XML_EntityDeclHandler handler);
    @@ -1835,7 +1907,8 @@ declarations.

    -
    +

    XML_GetCurrentByteIndex

    +
     XML_Index XMLCALL
     XML_GetCurrentByteIndex(XML_Parser p);
     
    @@ -1942,7 +2020,8 @@ the values returned by XML_GetCurrentColumnNumber. -
    +

    XML_GetCurrentLineNumber

    +
     XML_Size XMLCALL
     XML_GetCurrentLineNumber(XML_Parser p);
     
    @@ -1951,7 +2030,8 @@ Return the line number of the position. The first line is reported as 1. -
    +

    XML_GetCurrentColumnNumber

    +
     XML_Size XMLCALL
     XML_GetCurrentColumnNumber(XML_Parser p);
     
    @@ -1960,7 +2040,8 @@ Return the offset, from the beginning of the current line, of the position. -
    +

    XML_GetCurrentByteCount

    +
     int XMLCALL
     XML_GetCurrentByteCount(XML_Parser p);
     
    @@ -1972,7 +2053,8 @@ be used to distinguish empty-element tags from empty elements using separate start and end tags). -
    +

    XML_GetInputContext

    +
     const char * XMLCALL
     XML_GetInputContext(XML_Parser p,
                         int *offset,
    @@ -1998,12 +2080,105 @@ parse position may be before the beginning of the buffer.

    return NULL.

    +

    Billion Laughs Attack Protection

    + +

    The functions in this section configure the built-in + protection against various forms of + billion laughs attacks.

    + +

    XML_SetBillionLaughsAttackProtectionMaximumAmplification

    +
    +/* Added in Expat 2.4.0. */
    +XML_Bool XMLCALL
    +XML_SetBillionLaughsAttackProtectionMaximumAmplification(XML_Parser p,
    +                                                         float maximumAmplificationFactor);
    +
    +
    +

    + Sets the maximum tolerated amplification factor + for protection against + billion laughs attacks + (default: 100.0) + of parser p to maximumAmplificationFactor, and + returns XML_TRUE upon success and XML_TRUE upon error. +

    + + The amplification factor is calculated as .. +
    +    amplification := (direct + indirect) / direct
    +  
    + .. while parsing, whereas + direct is the number of bytes read from the primary document in parsing and + indirect is the number of bytes added by expanding entities and reading of external DTD files, combined. + +

    For a call to XML_SetBillionLaughsAttackProtectionMaximumAmplification to succeed:

    +
      +
    • parser p must be a non-NULL root parser (without any parent parsers) and
    • +
    • maximumAmplificationFactor must be non-NaN and greater than or equal to 1.0.
    • +
    + +

    + Note: + If you ever need to increase this value for non-attack payload, + please file a bug report. +

    + +

    + Note: + Peak amplifications + of factor 15,000 for the entire payload and + of factor 30,000 in the middle of parsing + have been observed with small benign files in practice. + + So if you do reduce the maximum allowed amplification, + please make sure that the activation threshold is still big enough + to not end up with undesired false positives (i.e. benign files being rejected). +

    +
    + +

    XML_SetBillionLaughsAttackProtectionActivationThreshold

    +
    +/* Added in Expat 2.4.0. */
    +XML_Bool XMLCALL
    +XML_SetBillionLaughsAttackProtectionActivationThreshold(XML_Parser p,
    +                                                        unsigned long long activationThresholdBytes);
    +
    +
    +

    + Sets number of output bytes (including amplification from entity expansion and reading DTD files) + needed to activate protection against + billion laughs attacks + (default: 8 MiB) + of parser p to activationThresholdBytes, and + returns XML_TRUE upon success and XML_TRUE upon error. +

    + +

    For a call to XML_SetBillionLaughsAttackProtectionActivationThreshold to succeed:

    +
      +
    • parser p must be a non-NULL root parser (without any parent parsers).
    • +
    + +

    + Note: + If you ever need to increase this value for non-attack payload, + please file a bug report. +

    + +

    + Note: + Activation thresholds below 4 MiB are known to break support for + DITA 1.3 payload + and are hence not recommended. +

    +
    +

    Miscellaneous functions

    The functions in this section either obtain state information from the parser or can be used to dynamically set parser options.

    -
    +

    XML_SetUserData

    +
     void XMLCALL
     XML_SetUserData(XML_Parser p,
                     void *userData);
    @@ -2018,7 +2193,8 @@ the memory associated with it, then you've probably just leaked
     memory.
     
     
    -
    +

    XML_GetUserData

    +
     void * XMLCALL
     XML_GetUserData(XML_Parser p);
     
    @@ -2027,7 +2203,8 @@ This returns the user data pointer that gets passed to handlers. It is actually implemented as a macro. -
    +

    XML_UseParserAsHandlerArg

    +
     void XMLCALL
     XML_UseParserAsHandlerArg(XML_Parser p);
     
    @@ -2038,7 +2215,8 @@ using the XML_GetUserData function. -
    +

    XML_SetBase

    +
     enum XML_Status XMLCALL
     XML_SetBase(XML_Parser p,
                 const XML_Char *base);
    @@ -2050,7 +2228,8 @@ there's no memory to store base, otherwise it's
     XML_STATUS_OK.
     
     
    -
    +

    XML_GetBase

    +
     const XML_Char * XMLCALL
     XML_GetBase(XML_Parser p);
     
    @@ -2058,7 +2237,8 @@ XML_GetBase(XML_Parser p); Return the base for resolving relative URIs. -
    +

    XML_GetSpecifiedAttributeCount

    +
     int XMLCALL
     XML_GetSpecifiedAttributeCount(XML_Parser p);
     
    @@ -2074,7 +2254,8 @@ call to a start handler. If called inside a start handler, then that means the current call. -
    +

    XML_GetIdAttributeIndex

    +
     int XMLCALL
     XML_GetIdAttributeIndex(XML_Parser p);
     
    @@ -2086,7 +2267,8 @@ attribute. If called inside a start handler, then that means the current call. -
    +

    XML_GetAttributeInfo

    +
     const XML_AttrInfo * XMLCALL
     XML_GetAttributeInfo(XML_Parser parser);
     
    @@ -2107,7 +2289,8 @@ as 1; thus the number of entries in the array is XML_GetSpecifiedAttributeCount(parser) / 2. -
    +

    XML_SetEncoding

    +
     enum XML_Status XMLCALL
     XML_SetEncoding(XML_Parser p,
                     const XML_Char *encoding);
    @@ -2122,7 +2305,8 @@ Returns XML_STATUS_OK on success or
     XML_STATUS_ERROR on error.
     
     
    -
    +

    XML_SetParamEntityParsing

    +
     int XMLCALL
     XML_SetParamEntityParsing(XML_Parser p,
                               enum XML_ParamEntityParsing code);
    @@ -2142,7 +2326,8 @@ The choices for code are:
     no effect and will always return 0.
     
     
    -
    +

    XML_SetHashSalt

    +
     int XMLCALL
     XML_SetHashSalt(XML_Parser p,
                     unsigned long hash_salt);
    @@ -2153,15 +2338,16 @@ Helps in preventing DoS attacks based on predicting hash
     function behavior. In order to have an effect this must be called
     before parsing has started. Returns 1 if successful, 0 when called
     after XML_Parse or XML_ParseBuffer.
    -

    Note:This call is optional, as the parser will auto-generate +

    Note: This call is optional, as the parser will auto-generate a new random salt value if no value has been set at the start of parsing.

    -

    Note:One should not call XML_SetHashSalt with a +

    Note: One should not call XML_SetHashSalt with a hash salt value of 0, as this value is used as sentinel value to indicate that XML_SetHashSalt has not been called. Consequently such a call will have no effect, even if it returns 1.

    -
    +

    XML_UseForeignDTD

    +
     enum XML_Error XMLCALL
     XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
     
    @@ -2198,7 +2384,8 @@ the document had a DTD with an external subset. This holds true even if the external entity reference handler returns without action.

    -
    +

    XML_SetReturnNSTriplet

    +
     void XMLCALL
     XML_SetReturnNSTriplet(XML_Parser parser,
                            int        do_nst);
    @@ -2220,7 +2407,8 @@ default manner, URI then local_name separated by the namespace
     separator.

    -
    +

    XML_DefaultCurrent

    +
     void XMLCALL
     XML_DefaultCurrent(XML_Parser parser);
     
    @@ -2234,7 +2422,8 @@ href="#XML_SetDefaultHandler" >XML_SetDefaultHandler or not a default handler. -
    +

    XML_ExpatVersion

    +
     XML_LChar * XMLCALL
     XML_ExpatVersion();
     
    @@ -2242,7 +2431,8 @@ XML_ExpatVersion(); Return the library version as a string (e.g. "expat_1.95.1"). -
    +

    XML_ExpatVersionInfo

    +
     struct XML_Expat_Version XMLCALL
     XML_ExpatVersionInfo();
     
    @@ -2266,7 +2456,8 @@ Testing these constants is currently the best way to determine if particular parts of the Expat API are available. -
    +

    XML_GetFeatureList

    +
     const XML_Feature * XMLCALL
     XML_GetFeatureList();
     
    @@ -2327,7 +2518,8 @@ time, the following features have been defined to have values:

    -
    +

    XML_FreeContentModel

    +
     void XMLCALL
     XML_FreeContentModel(XML_Parser parser, XML_Content *model);
     
    @@ -2346,7 +2538,8 @@ applications. This can be essential when using dynamically loaded libraries which use different C standard libraries (this can happen on Windows, at least).

    -
    +

    XML_MemMalloc

    +
     void * XMLCALL
     XML_MemMalloc(XML_Parser parser, size_t size);
     
    @@ -2358,7 +2551,8 @@ way must be freed using XML_MemFree. -
    +

    XML_MemRealloc

    +
     void * XMLCALL
     XML_MemRealloc(XML_Parser parser, void *ptr, size_t size);
     
    @@ -2377,7 +2571,8 @@ original block. Memory allocated in this way must be freed using >XML_MemFree. -
    +

    XML_MemFree

    +
     void XMLCALL
     XML_MemFree(XML_Parser parser, void *ptr);
     
    @@ -2388,9 +2583,12 @@ have been allocated by
    -

    Valid XHTML 1.0!

    + + + diff --git a/lib/libexpat/doc/style.css b/lib/libexpat/doc/style.css index 69df30bcecb..1b8cd10dffa 100644 --- a/lib/libexpat/doc/style.css +++ b/lib/libexpat/doc/style.css @@ -1,101 +1,47 @@ +/* + __ __ _ + ___\ \/ /_ __ __ _| |_ + / _ \\ /| '_ \ / _` | __| + | __// \| |_) | (_| | |_ + \___/_/\_\ .__/ \__,_|\__| + |_| XML parser + + Copyright (c) 2000 Clark Cooper + Copyright (c) 2000-2004 Fred L. Drake, Jr. + Copyright (c) 2021 Sebastian Pipping + Licensed under the MIT license: + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to permit + persons to whom the Software is furnished to do so, subject to the + following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +/* Stop not using half the screen */ body { - background-color: white; - border: 0px; - margin: 0px; - padding: 0px; -} - -.corner { - width: 200px; - height: 80px; - text-align: center; -} - -.banner { - background-color: rgb(110,139,61); - color: rgb(255,236,176); - padding-left: 2em; -} - -.banner h1 { - font-size: 200%; -} - -.content { - padding: 0em 2em 1em 2em; -} - -.releaseno { - background-color: rgb(110,139,61); - color: rgb(255,236,176); - padding-bottom: 0.3em; - padding-top: 0.5em; - text-align: center; - font-weight: bold; -} - -.noborder { - border-width: 0px; -} - -.eg { - padding-left: 1em; - padding-top: .5em; - padding-bottom: .5em; - border: solid thin; - margin: 1em 0; - background-color: tan; - margin-left: 2em; - margin-right: 10%; -} - -.pseudocode { - padding-left: 1em; - padding-top: .5em; - padding-bottom: .5em; - border: solid thin; - margin: 1em 0; - background-color: rgb(250,220,180); - margin-left: 2em; - margin-right: 10%; -} - -.handler { - width: 100%; - border-top-width: thin; - margin-bottom: 1em; -} - -.handler p { - margin-left: 2em; -} - -.setter { - font-weight: bold; -} - -.signature { - color: navy; -} - -.fcndec { - width: 100%; - border-top-width: thin; - font-weight: bold; -} - -.fcndef { - margin-left: 2em; - margin-bottom: 2em; -} - -dd { - margin-bottom: 2em; + max-width: none; /* was: 80ch */ } .cpp-symbols dt { font-family: monospace; } -.cpp-symbols dd { - margin-bottom: 1em; + +/* Resemble style of