git: 6b27d7f08077 - stable/14 - contrib/expat: import expat 2.10.0

From: Philip Paeps <philip_at_FreeBSD.org>
Date: Fri, 06 Nov 2026 01:20:06 UTC
The branch stable/14 has been updated by philip:

URL: https://cgit.FreeBSD.org/src/commit/?id=6b27d7f08077b64d1d1726e08fafa78b2bfdb252

commit 6b27d7f08077b64d1d1726e08fafa78b2bfdb252
Author:     Philip Paeps <philip@FreeBSD.org>
AuthorDate: 2026-11-02 15:11:05 +0000
Commit:     Philip Paeps <philip@FreeBSD.org>
CommitDate: 2026-11-05 23:35:29 +0000

    contrib/expat: import expat 2.10.0
    
    Changes: https://github.com/libexpat/libexpat/blob/R_2_10_0/expat/Changes
    
    Security:       CVE-2026-115506
    Security:       CVE-2026-117610
    Security:       CVE-2026-118370
    
    (cherry picked from commit 765f30b9f3af67a1db9619ff18862dc74ac72674)
    (cherry picked from commit a377d25bd25c0739d50c4dfe34ec2066821018d3)
---
 contrib/expat/Changes                |  89 ++++
 contrib/expat/README.md              |   2 +-
 contrib/expat/configure.ac           |   2 +-
 contrib/expat/doc/reference.html     |   8 +-
 contrib/expat/doc/xmlwf.1            |   2 +-
 contrib/expat/doc/xmlwf.xml          |   2 +-
 contrib/expat/lib/Makefile.am        |   5 +-
 contrib/expat/lib/Makefile.in        |   7 +-
 contrib/expat/lib/ascii.h            |   3 +-
 contrib/expat/lib/entities.h         |  99 ++++
 contrib/expat/lib/expat.h            |   5 +-
 contrib/expat/lib/expat_external.h   |   2 +-
 contrib/expat/lib/internal.h         |   8 +-
 contrib/expat/lib/xcs.c              |  21 +
 contrib/expat/lib/xcs.h              |   3 +
 contrib/expat/lib/xmlparse.c         | 871 +++++++++++++++++++++++++++++------
 contrib/expat/lib/xmltok.h           |   4 +-
 contrib/expat/lib/xmltok_impl.c      |   6 +-
 contrib/expat/tests/Makefile.am      |   7 +-
 contrib/expat/tests/Makefile.in      |  31 +-
 contrib/expat/tests/acc_tests.c      |  32 ++
 contrib/expat/tests/alloc_tests.c    |  42 ++
 contrib/expat/tests/basic_tests.c    |  63 ++-
 contrib/expat/tests/common.c         |  12 +
 contrib/expat/tests/common.h         |   2 +
 contrib/expat/tests/dummy.h          |   3 +
 contrib/expat/tests/entities_tests.c | 246 ++++++++++
 contrib/expat/tests/entities_tests.h |  41 ++
 contrib/expat/tests/handlers.h       |   1 +
 contrib/expat/tests/misc_tests.c     | 181 +++++++-
 contrib/expat/tests/runtests.c       |   2 +
 contrib/expat/tests/xcs_tests.c      |  23 +
 contrib/expat/xmlwf/Makefile.am      |   5 +-
 contrib/expat/xmlwf/Makefile.in      |   5 +-
 lib/libexpat/expat_config.h          |   6 +-
 lib/libexpat/libbsdxml.3             |   4 +-
 36 files changed, 1647 insertions(+), 198 deletions(-)

diff --git a/contrib/expat/Changes b/contrib/expat/Changes
index 91513379bb49..0124f81edbdd 100644
--- a/contrib/expat/Changes
+++ b/contrib/expat/Changes
@@ -21,6 +21,86 @@
 //                                   Sebastian Pipping -- Berlin, 2026-09-22 //
 ///////////////////////////////////////////////////////////////////////////////
 
+Release 2.10.0 Mon November 2 2026
+        Security fixes:
+           #1431  CVE-2026-113351 -- Fix denial of service with use of
+                    `XML_ParserReset`
+  #1433 #1436 ..
+  #1438 #1439 ..
+           #1442  CVE-2026-115506 -- Detect billion laughs attacks quicker
+                    and more of its variations. Related payload fuzzer at:
+                      https://github.com/hannob/lololol
+                    Please note that a layer of compression around XML can
+                    significantly reduce the minimum attack payload size.
+                    In case of backporting, please note pull request #1439
+                    in particular.
+           #1444  CVE-2026-117610 -- Fix initial non-final empty subparser
+                    parse calls. Was segfaulting previously.
+           #1450  CVE-2026-118370 -- Protect `attIndex` and `nPrefixes` in
+                    function `storeAtts` from signed integer overflow
+
+        Bug fixes:
+           #1452  lib: Initialize `m_parsingStatus.finalBuffer` in `parserInit`
+                    to fix calling `XML_GetParsingStatus` right after
+                    parser creation
+     #1457 #1459  lib: Improve `XML_Parse` for `XML_CONTEXT_BYTES == 0`
+                    including NULL pointer arithmetic undefined behavior
+                    and uninitialized variable access
+           #1458  lib: Use C99 length modifiers for `ptrdiff_t` and `size_t`
+                    to fix support for CHERI-RISC-V
+           #1461  lib: Check `isCalledFromInsideHandler` first in `XML_Parse`
+           #1467  lib: Add missing check for a character handler reset
+
+        Other changes:
+           #1441  Autotools: Move `-lm` from LDFLAGS to LIBADD/LDADD
+                    to better support compilation with `-Wl,--as-needed`
+           #1412  CMake: Support repeated `find_package` calls
+           #1413  lib: Address warning `XML_GE is not defined [-Werror=undef]`
+           #1415  lib: Stop delaying `callStoreEntityValue` error handling
+           #1415  lib: Add missing call to `poolDiscard`
+           #1437  lib: Add missing `NULL` check for `m_startDoctypeDeclHandler`
+           #1417  lib: Migrate `ENTITY.textLen` and `ENTITY.processed` from
+                         `int` to `size_t`
+           #1463  lib: Fix integer truncation in `XmlGetAttributes`/`getAtts`
+           #1420  lib: Some more `XML_Bool` to `bool` migration
+     #1449 #1460  lib: Document the memory reuse black magic that function
+                    `storeAtts` is doing
+           #1453  lib: Document failure to reject bad redefinitions of
+                    predefined entities
+           #1432  tests: Replace `XML_SetHashSalt` with
+                    `XML_SetHashSalt16Bytes`
+     #1416 #1435  Version info bumped from 14:0:13 (libexpat*.so.1.13.0)
+                    to 14:1:13 (libexpat*.so.1.13.1); see https://verbump.de/
+                    for what these numbers do
+
+        Infrastructure:
+           #1414  CI: Stop using about-to-be-removed image "macos-14"
+     #1418 #1434  CI: Bump MinGW Clang from 23.1.2 to 23.1.4
+           #1443  CI: Bump Fil-C from 0.686 to 0.687
+           #1456  Drop a `lib/xcsinc.c` leftover
+
+        Special thanks to:
+            Alexander Bluhm
+            Bartłomiej Dmitruk
+            Berkay Eren Ürün
+            Brooks Davis
+            brspoon
+            Funda Wang
+            Hanno Böck
+            Matthew Fernandez
+            Minkyung Park
+            Mirko Swillus
+            Pu Cheng
+            Scott Moore
+            Shani Yosef
+            Xisco Fauli
+                 and
+            City of Munich Open Source Sabbatical
+            echo.ai
+            Siemens
+            Striga
+            VulnCheck
+
 Release 2.9.0 Mon October 5 2026
         Security fixes:
            #1392  CVE-2026-102633 -- Integer overflow in function
@@ -106,6 +186,7 @@ Release 2.9.0 Mon October 5 2026
             Wade Sparks III
                  and
             City of Munich Open Source Sabbatical
+            Siemens
             VulnCheck
 
 Release 2.8.5 Tue September 22 2026
@@ -239,6 +320,7 @@ Release 2.8.4 Mon August 31 2026
                  and
             City of Munich Open Source Sabbatical
             Moonshot AI
+            Siemens
             VulnCheck
             Z.ai
 
@@ -425,6 +507,8 @@ Release 2.8.1 Sun May 10 2026
             Matthew Fernandez
             Nick Wellnhofer
             Tania Somanna
+                 and
+            Siemens
 
 Release 2.8.0 Fri April 24 2026
         Security fixes:
@@ -537,6 +621,7 @@ Release 2.7.5 Tue March 17 2026
             AddressSanitizer
             Buttercup
             OSS-Fuzz / ClusterFuzz
+            Siemens
             Trail of Bits
 
 Release 2.7.4 Sat January 31 2026
@@ -678,6 +763,7 @@ Release 2.7.3 Wed September 24 2025
                  and
             Clang/GCC UndefinedBehaviorSanitizer
             OSS-Fuzz / ClusterFuzz
+            Siemens
             Z3 Theorem Prover
 
 Release 2.7.2 Tue September 16 2025
@@ -791,6 +877,7 @@ Release 2.7.1 Thu March 27 2025
             Matthew Fernandez
                  and
             Perl XML::Parser
+            Siemens
 
 Release 2.7.0 Thu March 13 2025
         Security fixes:
@@ -950,6 +1037,8 @@ Release 2.6.3 Wed September 4 2024
             Dag-Erling Smørgrav
             Ferenc Géczi
             TaiYou
+                 and
+            Siemens
 
 Release 2.6.2 Wed March 13 2024
         Security fixes:
diff --git a/contrib/expat/README.md b/contrib/expat/README.md
index 1951645e8285..27e0dd481b18 100644
--- a/contrib/expat/README.md
+++ b/contrib/expat/README.md
@@ -17,7 +17,7 @@
 > Thank you! :heart: :pray:
 
 
-# Expat, Release 2.9.0
+# Expat, Release 2.10.0
 
 This is Expat, a C99 library for parsing
 [XML 1.0 Fourth Edition](https://www.w3.org/TR/2006/REC-xml-20060816/), started by
diff --git a/contrib/expat/configure.ac b/contrib/expat/configure.ac
index 6d80021cf0a9..cf61d6e47c6d 100644
--- a/contrib/expat/configure.ac
+++ b/contrib/expat/configure.ac
@@ -104,7 +104,7 @@ dnl If the API changes incompatibly set LIBAGE back to 0
 dnl
 
 LIBCURRENT=14  # sync
-LIBREVISION=0  # with
+LIBREVISION=1  # with
 LIBAGE=13      # CMakeLists.txt!
 
 AC_CONFIG_HEADERS([expat_config.h])
diff --git a/contrib/expat/doc/reference.html b/contrib/expat/doc/reference.html
index 2f892fd20b82..ebd5cf1913cf 100644
--- a/contrib/expat/doc/reference.html
+++ b/contrib/expat/doc/reference.html
@@ -53,7 +53,7 @@
   <body>
     <div>
       <h1>
-        The Expat XML Parser <small>Release 2.9.0</small>
+        The Expat XML Parser <small>Release 2.10.0</small>
       </h1>
     </div>
 
@@ -2862,6 +2862,12 @@ typedef void
           The <code>notationName</code> argument will have a non-<code>NULL</code> value
           only for unparsed entity declarations.
         </p>
+
+        <p>
+          <strong>Note:</strong> Length <code>value_length</code> can wrap around on
+          platforms where <code>int</code> is smaller than <code>size_t</code> including
+          <code>x86_64</code>.
+        </p>
       </div>
 
       <div class="handler">
diff --git a/contrib/expat/doc/xmlwf.1 b/contrib/expat/doc/xmlwf.1
index 22ca1d387b5f..ee683977cb26 100644
--- a/contrib/expat/doc/xmlwf.1
+++ b/contrib/expat/doc/xmlwf.1
@@ -5,7 +5,7 @@
 \\$2 \(la\\$1\(ra\\$3
 ..
 .if \n(.g .mso www.tmac
-.TH XMLWF 1 "October 5, 2026" "" ""
+.TH XMLWF 1 "November 2, 2026" "" ""
 .SH NAME
 xmlwf \- Determines if an XML document is well-formed
 .SH SYNOPSIS
diff --git a/contrib/expat/doc/xmlwf.xml b/contrib/expat/doc/xmlwf.xml
index 06880749583b..801bd35b2bf1 100644
--- a/contrib/expat/doc/xmlwf.xml
+++ b/contrib/expat/doc/xmlwf.xml
@@ -21,7 +21,7 @@
           "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
   <!ENTITY dhfirstname "<firstname>Scott</firstname>">
   <!ENTITY dhsurname   "<surname>Bronson</surname>">
-  <!ENTITY dhdate      "<date>October 5, 2026</date>">
+  <!ENTITY dhdate      "<date>November 2, 2026</date>">
   <!-- Please adjust this^^ date whenever cutting a new release. -->
   <!ENTITY dhsection   "<manvolnum>1</manvolnum>">
   <!ENTITY dhemail     "<email>bronson@rinspin.com</email>">
diff --git a/contrib/expat/lib/Makefile.am b/contrib/expat/lib/Makefile.am
index e4211b4dd3f9..97e7afa28493 100644
--- a/contrib/expat/lib/Makefile.am
+++ b/contrib/expat/lib/Makefile.am
@@ -12,6 +12,7 @@
 # Copyright (c) 2026      Gordon Messmer <gordon.messmer@gmail.com>
 # Copyright (c) 2026      Nick Begg <nick@stunttruck.net>
 # Copyright (c) 2026      Matthew Fernandez <matthew.fernandez@gmail.com>
+# Copyright (c) 2026      Funda Wang <fundawang@yeah.net>
 # Licensed under the MIT license:
 #
 # Permission is  hereby granted,  free of charge,  to any  person obtaining
@@ -45,13 +46,14 @@ endif
 
 libexpat_la_LDFLAGS = \
     @AM_LDFLAGS@ \
-    @LIBM@ \
     -no-undefined \
     -version-info @LIBCURRENT@:@LIBREVISION@:@LIBAGE@
 if HAVE_VSCRIPT
 libexpat_la_LDFLAGS += $(VSCRIPT_LDFLAGS),@builddir@/libexpat.map
 endif
 
+libexpat_la_LIBADD = @LIBM@
+
 libexpat_la_SOURCES = \
     xcs.c \
     xmlparse.c \
@@ -113,6 +115,7 @@ uninstall-local:
 EXTRA_DIST = \
     ascii.h \
     asciitab.h \
+    entities.h \
     expat_external.h \
     expat.h \
     fallthrough.h \
diff --git a/contrib/expat/lib/Makefile.in b/contrib/expat/lib/Makefile.in
index 4e5bb0bfd966..73ac70448b65 100644
--- a/contrib/expat/lib/Makefile.in
+++ b/contrib/expat/lib/Makefile.in
@@ -28,6 +28,7 @@
 # Copyright (c) 2026      Gordon Messmer <gordon.messmer@gmail.com>
 # Copyright (c) 2026      Nick Begg <nick@stunttruck.net>
 # Copyright (c) 2026      Matthew Fernandez <matthew.fernandez@gmail.com>
+# Copyright (c) 2026      Funda Wang <fundawang@yeah.net>
 # Licensed under the MIT license:
 #
 # Permission is  hereby granted,  free of charge,  to any  person obtaining
@@ -205,7 +206,7 @@ am__uninstall_files_from_dir = { \
 am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(docdir)" \
 	"$(DESTDIR)$(includedir)"
 LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES)
-libexpat_la_LIBADD =
+libexpat_la_DEPENDENCIES =
 am__libexpat_la_SOURCES_DIST = xcs.c xmlparse.c xmltok.c xmlrole.c \
 	random_arc4random.c random_arc4random.h \
 	random_arc4random_buf.c random_arc4random_buf.h \
@@ -493,8 +494,9 @@ include_HEADERS = \
 
 lib_LTLIBRARIES = libexpat.la
 @WITH_TESTS_TRUE@noinst_LTLIBRARIES = libtestpat.la
-libexpat_la_LDFLAGS = @AM_LDFLAGS@ @LIBM@ -no-undefined -version-info \
+libexpat_la_LDFLAGS = @AM_LDFLAGS@ -no-undefined -version-info \
 	@LIBCURRENT@:@LIBREVISION@:@LIBAGE@ $(am__append_1)
+libexpat_la_LIBADD = @LIBM@
 libexpat_la_SOURCES = xcs.c xmlparse.c xmltok.c xmlrole.c \
 	$(am__append_2) $(am__append_3) $(am__append_4) \
 	$(am__append_5) $(am__append_6) $(am__append_7)
@@ -507,6 +509,7 @@ doc_DATA = \
 EXTRA_DIST = \
     ascii.h \
     asciitab.h \
+    entities.h \
     expat_external.h \
     expat.h \
     fallthrough.h \
diff --git a/contrib/expat/lib/ascii.h b/contrib/expat/lib/ascii.h
index 1d9cf70bf695..d5d82bf41e82 100644
--- a/contrib/expat/lib/ascii.h
+++ b/contrib/expat/lib/ascii.h
@@ -10,7 +10,7 @@
    Copyright (c) 2000      Clark Cooper <coopercc@users.sourceforge.net>
    Copyright (c) 2002      Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
    Copyright (c) 2007      Karl Waclawek <karl@waclawek.net>
-   Copyright (c) 2017      Sebastian Pipping <sebastian@pipping.org>
+   Copyright (c) 2017-2026 Sebastian Pipping <sebastian@pipping.org>
    Licensed under the MIT license:
 
    Permission is  hereby granted,  free of charge,  to any  person obtaining
@@ -113,6 +113,7 @@
 #define ASCII_LT 0x3C
 #define ASCII_EQUALS 0x3D
 #define ASCII_GT 0x3E
+#define ASCII_QUEST 0x3F
 #define ASCII_LSQB 0x5B
 #define ASCII_RSQB 0x5D
 #define ASCII_UNDERSCORE 0x5F
diff --git a/contrib/expat/lib/entities.h b/contrib/expat/lib/entities.h
new file mode 100644
index 000000000000..51e3ed5c151b
--- /dev/null
+++ b/contrib/expat/lib/entities.h
@@ -0,0 +1,99 @@
+/* Internal helpers related to entities
+                            __  __            _
+                         ___\ \/ /_ __   __ _| |_
+                        / _ \\  /| '_ \ / _` | __|
+                       |  __//  \| |_) | (_| | |_
+                        \___/_/\_\ .__/ \__,_|\__|
+                                 |_| XML parser
+
+   Copyright (c) 2026 Sebastian Pipping <sebastian@pipping.org>
+   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.
+
+   SPDX-License-Identifier: MIT
+*/
+
+#if ! defined(EXPAT_ENTITIES_H)
+#  define EXPAT_ENTITIES_H 1
+
+#  include "expat_config.h"   // for XML_GE
+#  include "expat_external.h" // for XML_Char
+#  include "internal.h"       // for XML_NONTESTING_STATIC
+#  include <stdbool.h>        // for size_t
+#  include <stddef.h>         // for size_t
+
+typedef struct {
+  const XML_Char *name;
+  const XML_Char *textPtr;
+  size_t textLen;   /* length in XML_Chars */
+  size_t processed; /* # of processed bytes - when suspended */
+  const XML_Char *systemId;
+  const XML_Char *base;
+  const XML_Char *publicId;
+  const XML_Char *notation;
+  bool open;
+  bool hasMore; /* true if entity has not been completely processed */
+  /* An entity can be open while being already completely processed (!hasMore).
+    The reason is the delayed closing of entities until their inner
+    entities are processed and closed */
+  bool is_param;
+  bool is_internal; /* true if declared in internal subset outside PE */
+#  if XML_GE == 1
+  /* Indirect accounting bytes charged when this entity is expanded: 1 per text
+     character, plus each reference's "&name;"/"%name;" token length and its own
+     expansion. Matches XML_ACCOUNT_ENTITY_EXPANSION, so it is not the
+     replacement-text size. 0 means "not computed yet" (an empty entity is 0
+     too, told apart by textLen == 0). */
+  XmlBigCount expandedSize;
+  bool beingAnalyzed; /* on the resolveEntityClosureExpandedSize depth-first
+                             search stack; used for cycle detection */
+  const XML_Char
+      *scanPtr; /* cursor position into the entity's replacement text; NULL when
+                   `textPtr` is NULL, else a pointer into the entity value,
+                   ranging from `.textPtr` to `.textPtr + .textLen`. */
+#  endif        /* XML_GE == 1 */
+} ENTITY;
+
+#  if XML_GE == 1
+/* How a scanEntityText call ended. */
+enum EntityScanResult {
+  ENTITY_SCAN_COMPLETE, /* reached end of text; *expandedSize is final */
+  ENTITY_SCAN_BLOCKED,  /* stopped at a defined entity whose expanded
+                           size has not been computed yet; *blockerOut
+                           names the entity whose size to compute
+                           first */
+  ENTITY_SCAN_OVERFLOW  /* the expanded size would exceed XmlBigCount;
+                           callers must abort parsing */
+};
+
+XML_NONTESTING_STATIC int isCDataCommentOrPIStart(const XML_Char *pos,
+                                                  size_t maxLen,
+                                                  size_t *openTextLen);
+
+XML_NONTESTING_STATIC int isPredefinedEntityName(const XML_Char *name,
+                                                 size_t nameLen);
+
+XML_NONTESTING_STATIC enum EntityScanResult
+scanEntityText(XML_Parser parser, ENTITY *entity, const XML_Char **posPtr,
+               XmlBigCount *expandedSize, ENTITY **blockerOut);
+#  endif /* XML_GE == 1 */
+
+#endif // ! defined(EXPAT_ENTITIES_H)
diff --git a/contrib/expat/lib/expat.h b/contrib/expat/lib/expat.h
index 1b2852dd76cb..5756ed31936c 100644
--- a/contrib/expat/lib/expat.h
+++ b/contrib/expat/lib/expat.h
@@ -21,6 +21,7 @@
    Copyright (c) 2024      Taichi Haradaguchi <20001722@ymail.ne.jp>
    Copyright (c) 2025      Matthew Fernandez <matthew.fernandez@gmail.com>
    Copyright (c) 2026      Braian Plaku <braianplaku@gmail.com>
+   Copyright (c) 2026      Xisco Fauli <xiscofauli@libreoffice.org>
    Licensed under the MIT license:
 
    Permission is  hereby granted,  free of charge,  to any  person obtaining
@@ -1084,7 +1085,7 @@ enum XML_Parser_Property {
 #  if defined(XML_TESTING)
   XML_PROP_INVALID = 0,
 #  endif
-#  if XML_GE == 1
+#  if defined(XML_GE) && XML_GE == 1
   XML_PROP_ALLOC_TRACKER_ACTIVATION_THRESHOLD = 1,   // of type `uint64_t`
   XML_PROP_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION = 2,  // of type `double`
   XML_PROP_BILLION_LAUGHS_ACTIVATION_THRESHOLD = 3,  // of type `uint64_t`
@@ -1146,7 +1147,7 @@ XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled);
    See https://semver.org
 */
 #  define XML_MAJOR_VERSION 2
-#  define XML_MINOR_VERSION 9
+#  define XML_MINOR_VERSION 10
 #  define XML_MICRO_VERSION 0
 
 #  ifdef __cplusplus
diff --git a/contrib/expat/lib/expat_external.h b/contrib/expat/lib/expat_external.h
index 0620fe47ed3c..66be69ce3fe7 100644
--- a/contrib/expat/lib/expat_external.h
+++ b/contrib/expat/lib/expat_external.h
@@ -12,7 +12,7 @@
    Copyright (c) 2001-2002 Greg Stein <gstein@users.sourceforge.net>
    Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
    Copyright (c) 2016      Cristian Rodríguez <crrodriguez@opensuse.org>
-   Copyright (c) 2016-2025 Sebastian Pipping <sebastian@pipping.org>
+   Copyright (c) 2016-2026 Sebastian Pipping <sebastian@pipping.org>
    Copyright (c) 2017      Rhodri James <rhodri@wildebeest.org.uk>
    Copyright (c) 2018      Yury Gribov <tetra2005@gmail.com>
    Copyright (c) 2026      Matthew Fernandez <matthew.fernandez@gmail.com>
diff --git a/contrib/expat/lib/internal.h b/contrib/expat/lib/internal.h
index de34cd7dfc55..3c50a1e404ab 100644
--- a/contrib/expat/lib/internal.h
+++ b/contrib/expat/lib/internal.h
@@ -29,6 +29,7 @@
    Copyright (c) 2026      Matthew Wozniczka <mattheww@simba.com>
    Copyright (c) 2026      Braian Plaku <braianplaku@gmail.com>
    Copyright (c) 2026      Florian Schmaus <florian.schmaus@codasip.com>
+   Copyright (c) 2026      Brooks Davis <brooks@one-eyed-alien.net>
    Licensed under the MIT license:
 
    Permission is  hereby granted,  free of charge,  to any  person obtaining
@@ -90,11 +91,10 @@
 #      define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u"
 #    endif
 #  else
-#    include <inttypes.h> // PRIdPTR, PRIuPTR
 #    define EXPAT_FMT_LLX(midpart) "%" midpart "llx"
 #    define EXPAT_FMT_ULL(midpart) "%" midpart "llu"
-#    define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart PRIdPTR
-#    define EXPAT_FMT_SIZE_T(midpart) "%" midpart PRIuPTR
+#    define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "td"
+#    define EXPAT_FMT_SIZE_T(midpart) "%" midpart "zu"
 #  endif
 
 #  ifndef UNUSED_P
@@ -127,6 +127,8 @@ union expat_align {
 
 #  include "expat.h" // so we can use type XML_Parser below
 
+typedef unsigned long long XmlBigCount;
+
 void _INTERNAL_trim_to_complete_utf8_characters(const char *from,
                                                 const char **fromLimRef);
 
diff --git a/contrib/expat/lib/xcs.c b/contrib/expat/lib/xcs.c
index ae5e042d778f..a97647fa9d69 100644
--- a/contrib/expat/lib/xcs.c
+++ b/contrib/expat/lib/xcs.c
@@ -88,3 +88,24 @@ xcsncmp(const XML_Char *a, const XML_Char *b, size_t len) {
   return strncmp(a, b, len);
 #endif
 }
+
+// A port of `strnstr(3bsd)` to `XML_Char`
+const XML_Char *
+xcsnstr(const XML_Char *haystack, const XML_Char *needle, size_t maxLen) {
+  // NOTE: We are not calling `xcsnlen(haystack, maxLen)` because
+  //       `haystack` could be long and `xcsnlen` could be used in a loop
+  //       and we need to avoid quadratic runtime behavior.
+  if (! *needle)
+    return haystack; // i.e. empty needle is always a match
+  const size_t needleLen = xcslen(needle);
+  if (needleLen > maxLen)
+    return NULL;
+  const size_t maxTries = (maxLen - needleLen) + 1;
+  for (size_t i = 0; i < maxTries && haystack[i]; i++) {
+    if (haystack[i] == needle[0]
+        && xcsncmp(haystack + i, needle, needleLen) == 0) {
+      return haystack + i;
+    }
+  }
+  return NULL;
+}
diff --git a/contrib/expat/lib/xcs.h b/contrib/expat/lib/xcs.h
index 1b942647d333..9fbc4fe4c851 100644
--- a/contrib/expat/lib/xcs.h
+++ b/contrib/expat/lib/xcs.h
@@ -41,4 +41,7 @@ extern size_t xcslen(const XML_Char *s);
 extern int xcscmp(const XML_Char *a, const XML_Char *b);
 extern int xcsncmp(const XML_Char *a, const XML_Char *b, size_t len);
 
+extern const XML_Char *xcsnstr(const XML_Char *haystack, const XML_Char *needle,
+                               size_t maxLen);
+
 #endif // ! defined(EXPAT_XCS_H)
diff --git a/contrib/expat/lib/xmlparse.c b/contrib/expat/lib/xmlparse.c
index 41288b6ad418..5b4c60545fe3 100644
--- a/contrib/expat/lib/xmlparse.c
+++ b/contrib/expat/lib/xmlparse.c
@@ -1,4 +1,4 @@
-/* e3ca845466942140c9af531ac57808c4650116df5d6dbeda3b6546d2548a586e (2.9.0+)
+/* d0712c5efef760b5355ed61473a927256c6474aecb853016d2e335e571c64b0c (2.10.0+)
                             __  __            _
                          ___\ \/ /_ __   __ _| |_
                         / _ \\  /| '_ \ / _` | __|
@@ -58,6 +58,8 @@
    Copyright (c) 2026      Braian Plaku <braianplaku@gmail.com>
    Copyright (c) 2026      Filippo Tedeschi <filippotedeschi98@gmail.com>
    Copyright (c) 2026      Junki Lee <junkilee80@gmail.com>
+   Copyright (c) 2026      Shani Yosef <shani.yosef@echo.ai>
+   Copyright (c) 2026      Pu Cheng <geekshampoo@qq.com>
    Licensed under the MIT license:
 
    Permission is  hereby granted,  free of charge,  to any  person obtaining
@@ -227,11 +229,13 @@ typedef char ICHAR;
 
 /* Do safe (NULL-aware) pointer arithmetic */
 #define EXPAT_SAFE_PTR_DIFF(p, q) (((p) && (q)) ? ((p) - (q)) : 0)
+#define EXPAT_SAFE_PTR_ADD(p, a) ((p) ? ((p) + (a)) : NULL)
 
 #define EXPAT_MIN(a, b) (((a) < (b)) ? (a) : (b))
 
 #include "internal.h"
 #include "hash_table.h"
+#include "entities.h"
 #include "xmltok.h"
 #include "xmlrole.h"
 
@@ -309,24 +313,6 @@ typedef struct tag {
   BINDING *bindings;
 } TAG;
 
-typedef struct {
-  const XML_Char *name;
-  const XML_Char *textPtr;
-  int textLen;   /* length in XML_Chars */
-  int processed; /* # of processed bytes - when suspended */
-  const XML_Char *systemId;
-  const XML_Char *base;
-  const XML_Char *publicId;
-  const XML_Char *notation;
-  bool open;
-  bool hasMore; /* true if entity has not been completely processed */
-  /* An entity can be open while being already completely processed (!hasMore).
-    The reason is the delayed closing of entities until their inner
-    entities are processed and closed */
-  bool is_param;
-  bool is_internal; /* true if declared in internal subset outside PE */
-} ENTITY;
-
 typedef struct {
   enum XML_Content_Type type;
   enum XML_Content_Quant quant;
@@ -365,7 +351,7 @@ typedef struct attribute_id {
 
 typedef struct {
   const ATTRIBUTE_ID *id;
-  XML_Bool isCdata;
+  bool isCdata;
   const XML_Char *value;
 } DEFAULT_ATTRIBUTE;
 
@@ -455,7 +441,6 @@ enum XML_Account {
 };
 
 #if XML_GE == 1
-typedef unsigned long long XmlBigCount;
 typedef struct accounting {
   XmlBigCount countBytesDirect;
   XmlBigCount countBytesIndirect;
@@ -467,6 +452,7 @@ typedef struct accounting {
 typedef struct MALLOC_TRACKER {
   size_t bytesAllocated;
   size_t peakBytesAllocated; // updated live only for debug level >=2
+  size_t bytesAllocatedWhenLastReset;
   unsigned long debugLevel;
   float maximumAmplificationFactor; // >=1.0
   XmlBigCount activationThresholdBytes;
@@ -478,6 +464,13 @@ typedef struct entity_stats {
   unsigned int maximumDepthSeen;
   unsigned long debugLevel;
 } ENTITY_STATS;
+
+/* One pending entity-analysis task on the explicit stack used by
+   resolveEntityClosureExpandedSize's depth-first search over the entity
+   reference graph. */
+typedef struct {
+  ENTITY *entity; /* entity currently being scanned */
+} ENTITY_ANALYSIS_TASK;
 #endif /* XML_GE == 1 */
 
 typedef enum XML_Error Processor(XML_Parser parser, const char *start,
@@ -537,15 +530,15 @@ static enum XML_Error addBinding(XML_Parser parser, PREFIX *prefix,
                                  const ATTRIBUTE_ID *attId, const XML_Char *uri,
                                  BINDING **bindingsPtr);
 static int defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId,
-                           XML_Bool isCdata, XML_Bool isId,
-                           const XML_Char *value, XML_Parser parser);
+                           bool isCdata, bool isId, const XML_Char *value,
+                           XML_Parser parser);
 static enum XML_Error storeAttributeValue(XML_Parser parser,
-                                          const ENCODING *enc, XML_Bool isCdata,
+                                          const ENCODING *enc, bool isCdata,
                                           const char *ptr, const char *end,
                                           STRING_POOL *pool,
                                           enum XML_Account account);
 static enum XML_Error
-appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata,
+appendAttributeValue(XML_Parser parser, const ENCODING *enc, bool isCdata,
                      const char *ptr, const char *end, STRING_POOL *pool,
                      enum XML_Account account, const char **nextPtr);
 static ATTRIBUTE_ID *getAttributeId(XML_Parser parser, const ENCODING *enc,
@@ -560,6 +553,9 @@ static enum XML_Error callStoreEntityValue(XML_Parser parser,
                                            const ENCODING *enc,
                                            const char *start, const char *end,
                                            enum XML_Account account);
+static enum XML_Error resolveEntityClosureExpandedSize(XML_Parser parser,
+                                                       HASH_TABLE *table,
+                                                       ENTITY *root);
 #else
 static enum XML_Error storeSelfEntityValue(XML_Parser parser, ENTITY *entity);
 #endif
@@ -597,7 +593,7 @@ static const XML_Char *poolCopyString(STRING_POOL *pool, const XML_Char *s);
 static const XML_Char *poolCopyStringNoFinish(STRING_POOL *pool,
                                               const XML_Char *s);
 static const XML_Char *poolCopyStringN(STRING_POOL *pool, const XML_Char *s,
-                                       int n);
+                                       size_t n);
 static const XML_Char *poolAppendString(STRING_POOL *pool, const XML_Char *s);
 
 static int nextScaffoldPart(XML_Parser parser);
@@ -615,12 +611,17 @@ static XML_Parser parserCreate(const XML_Char *encodingName,
                                const XML_Char *nameSep, DTD *dtd,
                                XML_Parser parentParser);
 
-static void parserInit(XML_Parser parser, const XML_Char *encodingName);
+static void parserInit(XML_Parser parser, const XML_Char *encodingName,
+                       bool isReset);
 
 #if XML_GE == 1
-static float accountingGetCurrentAmplification(XML_Parser rootParser);
-static void accountingReportStats(XML_Parser originParser, const char *epilog);
-static void accountingOnAbort(XML_Parser originParser);
+static float accountingGetCurrentAmplification(XML_Parser rootParser,
+                                               XmlBigCount extraIndirectBytes);
+static void accountingReportStats(XML_Parser originParser, const char *epilog,
+                                  XmlBigCount extraIndirectBytes,
+                                  int sourceLine);
+static void accountingOnAbort(XML_Parser originParser,
+                              XmlBigCount extraIndirectBytes, int sourceLine);
 static void accountingReportDiff(XML_Parser rootParser,
                                  unsigned int levelsAwayFromRootParser,
                                  const char *before, const char *after,
@@ -630,6 +631,9 @@ static XML_Bool accountingDiffTolerated(XML_Parser originParser, int tok,
                                         const char *before, const char *after,
                                         int source_line,
                                         enum XML_Account account);
+static XML_Bool
+accountingCurrentAmplificationTolerated(XML_Parser rootParser,
+                                        XmlBigCount extraIndirectBytes);
 
 static void entityTrackingReportStats(XML_Parser parser, ENTITY *entity,
                                       const char *action, int sourceLine);
@@ -637,6 +641,10 @@ static void entityTrackingOnOpen(XML_Parser parser, ENTITY *entity,
                                  int sourceLine);
 static void entityTrackingOnClose(XML_Parser parser, ENTITY *entity,
                                   int sourceLine);
+static void entityTrackingOnScanStart(XML_Parser parser, ENTITY *entity,
+                                      int sourceLine);
+static void entityTrackingOnScanStop(XML_Parser parser, ENTITY *entity,
+                                     int sourceLine);
 #endif /* XML_GE == 1 */
 
 static XML_Parser getRootParserOf(XML_Parser parser,
@@ -792,8 +800,8 @@ struct XML_ParserStruct {
   const XML_Char *m_declNotationPublicId;
   ELEMENT_TYPE *m_declElementType;
   ATTRIBUTE_ID *m_declAttributeId;
-  XML_Bool m_declAttributeIsCdata;
-  XML_Bool m_declAttributeIsId;
+  bool m_declAttributeIsCdata;
+  bool m_declAttributeIsId;
   DTD *m_dtd;
   const XML_Char *m_curBase;
   TAG *m_tagStack;
@@ -865,11 +873,22 @@ expat_heap_increase_tolerable(XML_Parser rootParser, size_t increase,
   size_t newTotal = 0;
   bool tolerable = true;
 
+  // The idea is to subtract the amount of memory that was already
+  // allocated the last time that `XML_ParserReset` was called for
+  // this parser, the memory use of one document could skew the
+  // memory statso of the next document.
+  const size_t bytesAllocated
+      = (rootParser->m_alloc_tracker.bytesAllocatedWhenLastReset
+         > rootParser->m_alloc_tracker.bytesAllocated)
+            ? 0
+            : (rootParser->m_alloc_tracker.bytesAllocated
+               - rootParser->m_alloc_tracker.bytesAllocatedWhenLastReset);
+
   // Detect integer overflow
-  if (SIZE_MAX - rootParser->m_alloc_tracker.bytesAllocated < increase) {
+  if (SIZE_MAX - bytesAllocated < increase) {
     tolerable = false;
   } else {
-    newTotal = rootParser->m_alloc_tracker.bytesAllocated + increase;
+    newTotal = bytesAllocated + increase;
 
     if (newTotal >= rootParser->m_alloc_tracker.activationThresholdBytes) {
       assert(newTotal > 0);
@@ -1449,7 +1468,7 @@ parserCreate(const XML_Char *encodingName,
 
   poolInit(&parser->m_tempPool, parser);
   poolInit(&parser->m_temp2Pool, parser);
-  parserInit(parser, encodingName);
+  parserInit(parser, encodingName, /*isReset=*/false);
 
   if (encodingName && ! parser->m_protocolEncodingName) {
     if (dtd) {
@@ -1476,7 +1495,7 @@ parserCreate(const XML_Char *encodingName,
 }
 
 static void
-parserInit(XML_Parser parser, const XML_Char *encodingName) {
+parserInit(XML_Parser parser, const XML_Char *encodingName, bool isReset) {
   parser->m_processor = prologInitProcessor;
   XmlPrologStateInit(&parser->m_prologState);
   if (encodingName != NULL) {
@@ -1524,8 +1543,8 @@ parserInit(XML_Parser parser, const XML_Char *encodingName) {
   parser->m_declAttributeType = NULL;
   parser->m_declNotationName = NULL;
   parser->m_declNotationPublicId = NULL;
-  parser->m_declAttributeIsCdata = XML_FALSE;
-  parser->m_declAttributeIsId = XML_FALSE;
+  parser->m_declAttributeIsCdata = false;
+  parser->m_declAttributeIsId = false;
   memset(&parser->m_position, 0, sizeof(POSITION));
   parser->m_errorCode = XML_ERROR_NONE;
   parser->m_eventPtr = NULL;
@@ -1544,6 +1563,7 @@ parserInit(XML_Parser parser, const XML_Char *encodingName) {
   parser->m_unknownEncodingRelease = NULL;
   parser->m_unknownEncodingData = NULL;
   parser->m_parsingStatus.parsing = XML_INITIALIZED;
+  parser->m_parsingStatus.finalBuffer = XML_FALSE;
   // Reentry can only be triggered inside m_processor calls
   parser->m_reenter = XML_FALSE;
   parser->m_handlerCallDepth = 0;
@@ -1557,15 +1577,24 @@ parserInit(XML_Parser parser, const XML_Char *encodingName) {
   parser->m_hash_secret_salt_set = XML_FALSE;
 
 #if XML_GE == 1
-  memset(&parser->m_accounting, 0, sizeof(ACCOUNTING));
-  parser->m_accounting.debugLevel = getDebugLevel("EXPAT_ACCOUNTING_DEBUG", 0u);
-  parser->m_accounting.maximumAmplificationFactor
-      = EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT;
-  parser->m_accounting.activationThresholdBytes
-      = EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT;
-
-  memset(&parser->m_entity_stats, 0, sizeof(ENTITY_STATS));
-  parser->m_entity_stats.debugLevel = getDebugLevel("EXPAT_ENTITY_DEBUG", 0u);
+  parser->m_accounting.countBytesDirect = 0;
+  parser->m_accounting.countBytesIndirect = 0;
+  if (! isReset) {
+    parser->m_accounting.debugLevel
+        = getDebugLevel("EXPAT_ACCOUNTING_DEBUG", 0u);
+    parser->m_accounting.maximumAmplificationFactor
+        = EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT;
+    parser->m_accounting.activationThresholdBytes
+        = EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT;
+  }
+
+  parser->m_entity_stats.countEverOpened = 0;
+  parser->m_entity_stats.currentDepth = 0;
+  parser->m_entity_stats.maximumDepthSeen = 0;
+  if (! isReset)
+    parser->m_entity_stats.debugLevel = getDebugLevel("EXPAT_ENTITY_DEBUG", 0u);
+#else
+  UNUSED_P(isReset);
 #endif
 }
 
@@ -1628,8 +1657,16 @@ XML_ParserReset(XML_Parser parser, const XML_Char *encodingName) {
   poolClear(&parser->m_temp2Pool);
   FREE(parser, (void *)parser->m_protocolEncodingName);
   parser->m_protocolEncodingName = NULL;
-  parserInit(parser, encodingName);
+  parserInit(parser, encodingName, /*isReset=*/true);
   dtdReset(parser->m_dtd, parser);
+
+#if XML_GE == 1
+  parser->m_alloc_tracker.bytesAllocatedWhenLastReset
+      = parser->m_alloc_tracker.bytesAllocated;
+#endif
+
+  // NOTE: This effectively checks for `copyString` having failed during the
+  //       call to `parserInit` above
   if (encodingName && ! parser->m_protocolEncodingName) {
     parser->m_errorCode = XML_ERROR_NO_MEMORY;
     return XML_FALSE;
@@ -2299,13 +2336,12 @@ XML_SetHashSalt16Bytes(XML_Parser parser, const uint8_t entropy[16]) {
 
 enum XML_Status XMLCALL
 XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) {
-  if ((parser == NULL) || (len < 0) || ((s == NULL) && (len != 0))) {
-    if (parser != NULL)
-      parser->m_errorCode = XML_ERROR_INVALID_ARGUMENT;
+  if (parser == NULL || isCalledFromInsideHandler(parser))
     return XML_STATUS_ERROR;
-  }
-  if (isCalledFromInsideHandler(parser))
+  if ((len < 0) || ((s == NULL) && (len != 0))) {
+    parser->m_errorCode = XML_ERROR_INVALID_ARGUMENT;
     return XML_STATUS_ERROR;
+  }
   switch (parser->m_parsingStatus.parsing) {
   case XML_SUSPENDED:
     parser->m_errorCode = XML_ERROR_SUSPENDED;
@@ -2325,8 +2361,15 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) {
 
 #if XML_CONTEXT_BYTES == 0
   if (parser->m_bufferPtr == parser->m_bufferEnd) {
-    const char *end;
-    int nLeftOver;
+    // This null-object trick allows us to stop worrying about case `s == NULL`
+    // within this branch, e.g. with `s + len - end`.
+    const char *const empty = "";
+    if (s == NULL) {
+      assert(len == 0);
+      s = empty;
+    }
+    const char *end = s + len;
+    size_t nLeftOver;
     enum XML_Status result;
     /* Detect overflow (a+b > MAX <==> b > MAX-a) */
     if ((uint64_t)len > UINT64_MAX - parser->m_parseEndByteIndex) {
@@ -2343,7 +2386,7 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) {
     parser->m_parsingStatus.finalBuffer = (XML_Bool)isFinal;
 
     parser->m_errorCode
-        = callProcessor(parser, s, parser->m_parseEndPtr = s + len, &end);
+        = callProcessor(parser, s, parser->m_parseEndPtr = end, &end);
 
     if (parser->m_errorCode != XML_ERROR_NONE) {
       parser->m_eventEndPtr = parser->m_eventPtr;
@@ -2373,8 +2416,14 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) {
       // Back up and restore the parsing status to avoid XML_ERROR_SUSPENDED
       // (and XML_ERROR_FINISHED) from XML_GetBuffer.
       const enum XML_Parsing originalStatus = parser->m_parsingStatus.parsing;
+      if (nLeftOver > INT_MAX) {
+        parser->m_errorCode = XML_ERROR_NO_MEMORY;
+        parser->m_eventPtr = parser->m_eventEndPtr = NULL;
+        parser->m_processor = errorProcessor;
+        return XML_STATUS_ERROR;
+      }
       parser->m_parsingStatus.parsing = XML_PARSING;
-      void *const temp = XML_GetBuffer(parser, nLeftOver);
+      void *const temp = XML_GetBuffer(parser, (int)nLeftOver);
       parser->m_parsingStatus.parsing = originalStatus;
       // GetBuffer may have overwritten this, but we want to remember what the
       // app requested, not how many bytes were left over after parsing.
@@ -2392,7 +2441,7 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) {
       memcpy(parser->m_buffer, end, nLeftOver);
     }
     parser->m_bufferPtr = parser->m_buffer;
-    parser->m_bufferEnd = parser->m_buffer + nLeftOver;
+    parser->m_bufferEnd = EXPAT_SAFE_PTR_ADD(parser->m_buffer, nLeftOver);
     parser->m_positionPtr = parser->m_bufferPtr;
     parser->m_parseEndPtr = parser->m_bufferEnd;
     parser->m_eventPtr = parser->m_bufferPtr;
@@ -3474,7 +3523,7 @@ externalEntityInitProcessor2(XML_Parser parser, const char *start,
 #if XML_GE == 1
     if (! accountingDiffTolerated(parser, tok, start, next, __LINE__,
                                   XML_ACCOUNT_DIRECT)) {
-      accountingOnAbort(parser);
+      accountingOnAbort(parser, 0, __LINE__);
*** 2310 LINES SKIPPED ***