Merge topic 'update-expat'

4915573522 expat: Remove unused try_compile check
a3be099700 Merge branch 'upstream-expat' into update-expat
8cb2e8acde expat 2026-03-17 (f31adfd5)
863a712f16 expat: Update script to get Expat 2.7.5

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12543
This commit is contained in:
Brad King
2026-09-23 13:44:30 -04:00
committed by Kitware Robot
11 changed files with 132 additions and 95 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ readonly name="expat"
readonly ownership="Expat Upstream <kwrobot@kitware.com>" readonly ownership="Expat Upstream <kwrobot@kitware.com>"
readonly subtree="Utilities/cmexpat" readonly subtree="Utilities/cmexpat"
readonly repo="https://github.com/libexpat/libexpat.git" readonly repo="https://github.com/libexpat/libexpat.git"
readonly tag="R_2_7_3" readonly tag="R_2_7_5"
readonly shortlog=false readonly shortlog=false
readonly exact_tree_match=false readonly exact_tree_match=false
readonly paths=" readonly paths="
+2 -8
View File
@@ -22,15 +22,9 @@ check_symbol_exists("getpagesize" "unistd.h" HAVE_GETPAGESIZE)
check_symbol_exists("mmap" "sys/mman.h" HAVE_MMAP) check_symbol_exists("mmap" "sys/mman.h" HAVE_MMAP)
check_symbol_exists("getrandom" "sys/random.h" HAVE_GETRANDOM) check_symbol_exists("getrandom" "sys/random.h" HAVE_GETRANDOM)
if(EXPAT_WITH_LIBBSD) check_symbol_exists("arc4random_buf" "stdlib.h" HAVE_ARC4RANDOM_BUF)
set(CMAKE_REQUIRED_LIBRARIES "${LIB_BSD}")
set(_bsd "bsd/")
else()
set(_bsd "")
endif()
check_symbol_exists("arc4random_buf" "${_bsd}stdlib.h" HAVE_ARC4RANDOM_BUF)
if(NOT HAVE_ARC4RANDOM_BUF) if(NOT HAVE_ARC4RANDOM_BUF)
check_symbol_exists("arc4random" "${_bsd}stdlib.h" HAVE_ARC4RANDOM) check_symbol_exists("arc4random" "stdlib.h" HAVE_ARC4RANDOM)
endif() endif()
set(CMAKE_REQUIRED_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES)
+4 -9
View File
@@ -11,7 +11,7 @@
> at the top of the `Changes` file. > at the top of the `Changes` file.
# Expat, Release 2.7.3 # Expat, Release 2.7.5
This is Expat, a C99 library for parsing This is Expat, a C99 library for parsing
[XML 1.0 Fourth Edition](https://www.w3.org/TR/2006/REC-xml-20060816/), started by [XML 1.0 Fourth Edition](https://www.w3.org/TR/2006/REC-xml-20060816/), started by
@@ -234,11 +234,6 @@ overrides the in-makefile set `DESTDIR`, because variable-setting priority is
Note: This only applies to the Expat library itself, building UTF-16 versions Note: This only applies to the Expat library itself, building UTF-16 versions
of xmlwf and the tests is currently not supported. of xmlwf and the tests is currently not supported.
When using Expat with a project using autoconf for configuration, you
can use the probing macro in `conftools/expat.m4` to determine how to
include Expat. See the comments at the top of that file for more
information.
A reference manual is available in the file `doc/reference.html` in this A reference manual is available in the file `doc/reference.html` in this
distribution. distribution.
@@ -297,15 +292,15 @@ EXPAT_OSSFUZZ_BUILD:BOOL=OFF
// Build a shared expat library // Build a shared expat library
EXPAT_SHARED_LIBS:BOOL=ON EXPAT_SHARED_LIBS:BOOL=ON
// Define to provide symbol versioning for dependency generation
EXPAT_SYMBOL_VERSIONING:BOOL=OFF
// Treat all compiler warnings as errors // Treat all compiler warnings as errors
EXPAT_WARNINGS_AS_ERRORS:BOOL=OFF EXPAT_WARNINGS_AS_ERRORS:BOOL=OFF
// Make use of getrandom function (ON|OFF|AUTO) [default=AUTO] // Make use of getrandom function (ON|OFF|AUTO) [default=AUTO]
EXPAT_WITH_GETRANDOM:STRING=AUTO EXPAT_WITH_GETRANDOM:STRING=AUTO
// Utilize libbsd (for arc4random_buf)
EXPAT_WITH_LIBBSD:BOOL=OFF
// Make use of syscall SYS_getrandom (ON|OFF|AUTO) [default=AUTO] // Make use of syscall SYS_getrandom (ON|OFF|AUTO) [default=AUTO]
EXPAT_WITH_SYS_GETRANDOM:STRING=AUTO EXPAT_WITH_SYS_GETRANDOM:STRING=AUTO
``` ```
-3
View File
@@ -27,9 +27,6 @@
/* Define to 1 if you have the <inttypes.h> header file. */ /* Define to 1 if you have the <inttypes.h> header file. */
#cmakedefine HAVE_INTTYPES_H #cmakedefine HAVE_INTTYPES_H
/* Define to 1 if you have the `bsd' library (-lbsd). */
#cmakedefine HAVE_LIBBSD
/* Define to 1 if you have the <memory.h> header file. */ /* Define to 1 if you have the <memory.h> header file. */
#cmakedefine HAVE_MEMORY_H #cmakedefine HAVE_MEMORY_H
+2 -2
View File
@@ -11,7 +11,7 @@
Copyright (c) 2000-2005 Fred L. Drake, Jr. <fdrake@users.sourceforge.net> Copyright (c) 2000-2005 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2001-2002 Greg Stein <gstein@users.sourceforge.net> Copyright (c) 2001-2002 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2002-2016 Karl Waclawek <karl@waclawek.net> Copyright (c) 2002-2016 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2016-2025 Sebastian Pipping <sebastian@pipping.org> Copyright (c) 2016-2026 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2016 Cristian Rodríguez <crrodriguez@opensuse.org> Copyright (c) 2016 Cristian Rodríguez <crrodriguez@opensuse.org>
Copyright (c) 2016 Thomas Beutlich <tc@tbeu.de> Copyright (c) 2016 Thomas Beutlich <tc@tbeu.de>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk> Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
@@ -1082,7 +1082,7 @@ XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled);
*/ */
# define XML_MAJOR_VERSION 2 # define XML_MAJOR_VERSION 2
# define XML_MINOR_VERSION 7 # define XML_MINOR_VERSION 7
# define XML_MICRO_VERSION 3 # define XML_MICRO_VERSION 5
# ifdef __cplusplus # ifdef __cplusplus
} }
+2 -3
View File
@@ -12,7 +12,7 @@
Copyright (c) 2001-2002 Greg Stein <gstein@users.sourceforge.net> Copyright (c) 2001-2002 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net> Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2016 Cristian Rodríguez <crrodriguez@opensuse.org> Copyright (c) 2016 Cristian Rodríguez <crrodriguez@opensuse.org>
Copyright (c) 2016-2019 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) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2018 Yury Gribov <tetra2005@gmail.com> Copyright (c) 2018 Yury Gribov <tetra2005@gmail.com>
Licensed under the MIT license: Licensed under the MIT license:
@@ -91,8 +91,7 @@
# ifndef XML_BUILDING_EXPAT # ifndef XML_BUILDING_EXPAT
/* using Expat from an application */ /* using Expat from an application */
# if defined(_MSC_EXTENSIONS) && ! defined(__BEOS__) \ # if defined(_MSC_VER) && ! defined(__BEOS__) && ! defined(__CYGWIN__)
&& ! defined(__CYGWIN__)
# define XMLIMPORT __declspec(dllimport) # define XMLIMPORT __declspec(dllimport)
# endif # endif
+1 -1
View File
@@ -128,7 +128,7 @@
# elif ULONG_MAX == 18446744073709551615u // 2^64-1 # elif ULONG_MAX == 18446744073709551615u // 2^64-1
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld" # define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld"
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "lu" # define EXPAT_FMT_SIZE_T(midpart) "%" midpart "lu"
# elif defined(EMSCRIPTEN) // 32bit mode Emscripten # elif defined(__wasm32__) // 32bit mode Emscripten or WASI SDK
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld" # define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld"
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "zu" # define EXPAT_FMT_SIZE_T(midpart) "%" midpart "zu"
# else # else
+112 -61
View File
@@ -1,4 +1,4 @@
/* 28bcd8b1ba7eb595d82822908257fd9c3589b4243e3c922d0369f35bfcd7b506 (2.7.3+) /* 93c1caa66e2b0310459482516af05505b57c5cb7b96df777105308fc585c85d1 (2.7.5+)
__ __ _ __ __ _
___\ \/ /_ __ __ _| |_ ___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __| / _ \\ /| '_ \ / _` | __|
@@ -13,7 +13,7 @@
Copyright (c) 2002-2016 Karl Waclawek <karl@waclawek.net> Copyright (c) 2002-2016 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2005-2009 Steven Solie <steven@solie.ca> Copyright (c) 2005-2009 Steven Solie <steven@solie.ca>
Copyright (c) 2016 Eric Rahm <erahm@mozilla.com> Copyright (c) 2016 Eric Rahm <erahm@mozilla.com>
Copyright (c) 2016-2025 Sebastian Pipping <sebastian@pipping.org> Copyright (c) 2016-2026 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2016 Gaurav <g.gupta@samsung.com> Copyright (c) 2016 Gaurav <g.gupta@samsung.com>
Copyright (c) 2016 Thomas Beutlich <tc@tbeu.de> Copyright (c) 2016 Thomas Beutlich <tc@tbeu.de>
Copyright (c) 2016 Gustavo Grieco <gustavo.grieco@imag.fr> Copyright (c) 2016 Gustavo Grieco <gustavo.grieco@imag.fr>
@@ -42,6 +42,9 @@
Copyright (c) 2024-2025 Berkay Eren Ürün <berkay.ueruen@siemens.com> Copyright (c) 2024-2025 Berkay Eren Ürün <berkay.ueruen@siemens.com>
Copyright (c) 2024 Hanno Böck <hanno@gentoo.org> Copyright (c) 2024 Hanno Böck <hanno@gentoo.org>
Copyright (c) 2025 Matthew Fernandez <matthew.fernandez@gmail.com> Copyright (c) 2025 Matthew Fernandez <matthew.fernandez@gmail.com>
Copyright (c) 2025 Atrem Borovik <polzovatellllk@gmail.com>
Copyright (c) 2025 Alfonso Gregory <gfunni234@gmail.com>
Copyright (c) 2026 Rosen Penev <rosenp@gmail.com>
Licensed under the MIT license: Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
@@ -101,7 +104,7 @@
#include <limits.h> /* INT_MAX, UINT_MAX */ #include <limits.h> /* INT_MAX, UINT_MAX */
#include <stdio.h> /* fprintf */ #include <stdio.h> /* fprintf */
#include <stdlib.h> /* getenv, rand_s */ #include <stdlib.h> /* getenv, rand_s */
#include <stdint.h> /* uintptr_t */ #include <stdint.h> /* SIZE_MAX, uintptr_t */
#include <math.h> /* isnan */ #include <math.h> /* isnan */
#ifdef _WIN32 #ifdef _WIN32
@@ -134,11 +137,6 @@
# endif /* defined(GRND_NONBLOCK) */ # endif /* defined(GRND_NONBLOCK) */
#endif /* defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) */ #endif /* defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) */
#if defined(HAVE_LIBBSD) \
&& (defined(HAVE_ARC4RANDOM_BUF) || defined(HAVE_ARC4RANDOM))
# include <bsd/stdlib.h>
#endif
#if defined(_WIN32) && ! defined(LOAD_LIBRARY_SEARCH_SYSTEM32) #if defined(_WIN32) && ! defined(LOAD_LIBRARY_SEARCH_SYSTEM32)
# define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 # define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
#endif #endif
@@ -155,8 +153,6 @@
* Linux >=3.17 + glibc (including <2.25) (syscall SYS_getrandom): HAVE_SYSCALL_GETRANDOM, \ * Linux >=3.17 + glibc (including <2.25) (syscall SYS_getrandom): HAVE_SYSCALL_GETRANDOM, \
* BSD / macOS >=10.7 / glibc >=2.36 (arc4random_buf): HAVE_ARC4RANDOM_BUF, \ * BSD / macOS >=10.7 / glibc >=2.36 (arc4random_buf): HAVE_ARC4RANDOM_BUF, \
* BSD / macOS (including <10.7) / glibc >=2.36 (arc4random): HAVE_ARC4RANDOM, \ * BSD / macOS (including <10.7) / glibc >=2.36 (arc4random): HAVE_ARC4RANDOM, \
* libbsd (arc4random_buf): HAVE_ARC4RANDOM_BUF + HAVE_LIBBSD, \
* libbsd (arc4random): HAVE_ARC4RANDOM + HAVE_LIBBSD, \
* Linux (including <3.17) / BSD / macOS (including <10.7) / Solaris >=8 (/dev/urandom): XML_DEV_URANDOM, \ * Linux (including <3.17) / BSD / macOS (including <10.7) / Solaris >=8 (/dev/urandom): XML_DEV_URANDOM, \
* Windows >=Vista (rand_s): _WIN32. \ * Windows >=Vista (rand_s): _WIN32. \
\ \
@@ -311,8 +307,11 @@ typedef struct tag {
const char *rawName; /* tagName in the original encoding */ const char *rawName; /* tagName in the original encoding */
int rawNameLength; int rawNameLength;
TAG_NAME name; /* tagName in the API encoding */ TAG_NAME name; /* tagName in the API encoding */
char *buf; /* buffer for name components */ union {
char *bufEnd; /* end of the buffer */ char *raw; /* for byte-level access (rawName storage) */
XML_Char *str; /* for character-level access (converted name) */
} buf; /* buffer for name components */
char *bufEnd; /* end of the buffer */
BINDING *bindings; BINDING *bindings;
} TAG; } TAG;
@@ -349,7 +348,7 @@ typedef struct {
typedef struct block { typedef struct block {
struct block *next; struct block *next;
int size; int size;
XML_Char s[1]; XML_Char s[];
} BLOCK; } BLOCK;
typedef struct { typedef struct {
@@ -591,6 +590,8 @@ static XML_Char *poolStoreString(STRING_POOL *pool, const ENCODING *enc,
static XML_Bool FASTCALL poolGrow(STRING_POOL *pool); static XML_Bool FASTCALL poolGrow(STRING_POOL *pool);
static const XML_Char *FASTCALL poolCopyString(STRING_POOL *pool, static const XML_Char *FASTCALL poolCopyString(STRING_POOL *pool,
const XML_Char *s); const XML_Char *s);
static const XML_Char *FASTCALL poolCopyStringNoFinish(STRING_POOL *pool,
const XML_Char *s);
static const XML_Char *poolCopyStringN(STRING_POOL *pool, const XML_Char *s, static const XML_Char *poolCopyStringN(STRING_POOL *pool, const XML_Char *s,
int n); int n);
static const XML_Char *FASTCALL poolAppendString(STRING_POOL *pool, static const XML_Char *FASTCALL poolAppendString(STRING_POOL *pool,
@@ -1230,8 +1231,11 @@ generate_hash_secret_salt(XML_Parser parser) {
# endif /* ! defined(_WIN32) && defined(XML_DEV_URANDOM) */ # endif /* ! defined(_WIN32) && defined(XML_DEV_URANDOM) */
/* .. and self-made low quality for backup: */ /* .. and self-made low quality for backup: */
entropy = gather_time_entropy();
# if ! defined(__wasi__)
/* Process ID is 0 bits entropy if attacker has local access */ /* Process ID is 0 bits entropy if attacker has local access */
entropy = gather_time_entropy() ^ getpid(); entropy ^= getpid();
# endif
/* Factors are 2^31-1 and 2^61-1 (Mersenne primes M31 and M61) */ /* Factors are 2^31-1 and 2^61-1 (Mersenne primes M31 and M61) */
if (sizeof(unsigned long) == 4) { if (sizeof(unsigned long) == 4) {
@@ -1754,6 +1758,7 @@ XML_ExternalEntityParserCreate(XML_Parser oldParser, const XML_Char *context,
XML_ExternalEntityRefHandler oldExternalEntityRefHandler; XML_ExternalEntityRefHandler oldExternalEntityRefHandler;
XML_SkippedEntityHandler oldSkippedEntityHandler; XML_SkippedEntityHandler oldSkippedEntityHandler;
XML_UnknownEncodingHandler oldUnknownEncodingHandler; XML_UnknownEncodingHandler oldUnknownEncodingHandler;
void *oldUnknownEncodingHandlerData;
XML_ElementDeclHandler oldElementDeclHandler; XML_ElementDeclHandler oldElementDeclHandler;
XML_AttlistDeclHandler oldAttlistDeclHandler; XML_AttlistDeclHandler oldAttlistDeclHandler;
XML_EntityDeclHandler oldEntityDeclHandler; XML_EntityDeclHandler oldEntityDeclHandler;
@@ -1799,6 +1804,7 @@ XML_ExternalEntityParserCreate(XML_Parser oldParser, const XML_Char *context,
oldExternalEntityRefHandler = parser->m_externalEntityRefHandler; oldExternalEntityRefHandler = parser->m_externalEntityRefHandler;
oldSkippedEntityHandler = parser->m_skippedEntityHandler; oldSkippedEntityHandler = parser->m_skippedEntityHandler;
oldUnknownEncodingHandler = parser->m_unknownEncodingHandler; oldUnknownEncodingHandler = parser->m_unknownEncodingHandler;
oldUnknownEncodingHandlerData = parser->m_unknownEncodingHandlerData;
oldElementDeclHandler = parser->m_elementDeclHandler; oldElementDeclHandler = parser->m_elementDeclHandler;
oldAttlistDeclHandler = parser->m_attlistDeclHandler; oldAttlistDeclHandler = parser->m_attlistDeclHandler;
oldEntityDeclHandler = parser->m_entityDeclHandler; oldEntityDeclHandler = parser->m_entityDeclHandler;
@@ -1859,6 +1865,7 @@ XML_ExternalEntityParserCreate(XML_Parser oldParser, const XML_Char *context,
parser->m_externalEntityRefHandler = oldExternalEntityRefHandler; parser->m_externalEntityRefHandler = oldExternalEntityRefHandler;
parser->m_skippedEntityHandler = oldSkippedEntityHandler; parser->m_skippedEntityHandler = oldSkippedEntityHandler;
parser->m_unknownEncodingHandler = oldUnknownEncodingHandler; parser->m_unknownEncodingHandler = oldUnknownEncodingHandler;
parser->m_unknownEncodingHandlerData = oldUnknownEncodingHandlerData;
parser->m_elementDeclHandler = oldElementDeclHandler; parser->m_elementDeclHandler = oldElementDeclHandler;
parser->m_attlistDeclHandler = oldAttlistDeclHandler; parser->m_attlistDeclHandler = oldAttlistDeclHandler;
parser->m_entityDeclHandler = oldEntityDeclHandler; parser->m_entityDeclHandler = oldEntityDeclHandler;
@@ -1934,7 +1941,7 @@ XML_ParserFree(XML_Parser parser) {
} }
p = tagList; p = tagList;
tagList = tagList->parent; tagList = tagList->parent;
FREE(parser, p->buf); FREE(parser, p->buf.raw);
destroyBindings(p->bindings, parser); destroyBindings(p->bindings, parser);
FREE(parser, p); FREE(parser, p);
} }
@@ -2599,7 +2606,7 @@ XML_GetBuffer(XML_Parser parser, int len) {
// NOTE: We are avoiding MALLOC(..) here to leave limiting // NOTE: We are avoiding MALLOC(..) here to leave limiting
// the input size to the application using Expat. // the input size to the application using Expat.
newBuf = parser->m_mem.malloc_fcn(bufferSize); newBuf = parser->m_mem.malloc_fcn(bufferSize);
if (newBuf == 0) { if (newBuf == NULL) {
parser->m_errorCode = XML_ERROR_NO_MEMORY; parser->m_errorCode = XML_ERROR_NO_MEMORY;
return NULL; return NULL;
} }
@@ -3126,7 +3133,7 @@ storeRawNames(XML_Parser parser) {
size_t bufSize; size_t bufSize;
size_t nameLen = sizeof(XML_Char) * (tag->name.strLen + 1); size_t nameLen = sizeof(XML_Char) * (tag->name.strLen + 1);
size_t rawNameLen; size_t rawNameLen;
char *rawNameBuf = tag->buf + nameLen; char *rawNameBuf = tag->buf.raw + nameLen;
/* Stop if already stored. Since m_tagStack is a stack, we can stop /* Stop if already stored. Since m_tagStack is a stack, we can stop
at the first entry that has already been copied; everything at the first entry that has already been copied; everything
below it in the stack is already been accounted for in a below it in the stack is already been accounted for in a
@@ -3142,22 +3149,22 @@ storeRawNames(XML_Parser parser) {
if (rawNameLen > (size_t)INT_MAX - nameLen) if (rawNameLen > (size_t)INT_MAX - nameLen)
return XML_FALSE; return XML_FALSE;
bufSize = nameLen + rawNameLen; bufSize = nameLen + rawNameLen;
if (bufSize > (size_t)(tag->bufEnd - tag->buf)) { if (bufSize > (size_t)(tag->bufEnd - tag->buf.raw)) {
char *temp = REALLOC(parser, tag->buf, bufSize); char *temp = REALLOC(parser, tag->buf.raw, bufSize);
if (temp == NULL) if (temp == NULL)
return XML_FALSE; return XML_FALSE;
/* if tag->name.str points to tag->buf (only when namespace /* if tag->name.str points to tag->buf.str (only when namespace
processing is off) then we have to update it processing is off) then we have to update it
*/ */
if (tag->name.str == (XML_Char *)tag->buf) if (tag->name.str == tag->buf.str)
tag->name.str = (XML_Char *)temp; tag->name.str = (XML_Char *)temp;
/* if tag->name.localPart is set (when namespace processing is on) /* if tag->name.localPart is set (when namespace processing is on)
then update it as well, since it will always point into tag->buf then update it as well, since it will always point into tag->buf
*/ */
if (tag->name.localPart) if (tag->name.localPart)
tag->name.localPart tag->name.localPart
= (XML_Char *)temp + (tag->name.localPart - (XML_Char *)tag->buf); = (XML_Char *)temp + (tag->name.localPart - tag->buf.str);
tag->buf = temp; tag->buf.raw = temp;
tag->bufEnd = temp + bufSize; tag->bufEnd = temp + bufSize;
rawNameBuf = temp + nameLen; rawNameBuf = temp + nameLen;
} }
@@ -3472,12 +3479,12 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
tag = MALLOC(parser, sizeof(TAG)); tag = MALLOC(parser, sizeof(TAG));
if (! tag) if (! tag)
return XML_ERROR_NO_MEMORY; return XML_ERROR_NO_MEMORY;
tag->buf = MALLOC(parser, INIT_TAG_BUF_SIZE); tag->buf.raw = MALLOC(parser, INIT_TAG_BUF_SIZE);
if (! tag->buf) { if (! tag->buf.raw) {
FREE(parser, tag); FREE(parser, tag);
return XML_ERROR_NO_MEMORY; return XML_ERROR_NO_MEMORY;
} }
tag->bufEnd = tag->buf + INIT_TAG_BUF_SIZE; tag->bufEnd = tag->buf.raw + INIT_TAG_BUF_SIZE;
} }
tag->bindings = NULL; tag->bindings = NULL;
tag->parent = parser->m_tagStack; tag->parent = parser->m_tagStack;
@@ -3490,31 +3497,32 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
{ {
const char *rawNameEnd = tag->rawName + tag->rawNameLength; const char *rawNameEnd = tag->rawName + tag->rawNameLength;
const char *fromPtr = tag->rawName; const char *fromPtr = tag->rawName;
toPtr = (XML_Char *)tag->buf; toPtr = tag->buf.str;
for (;;) { for (;;) {
int bufSize;
int convLen; int convLen;
const enum XML_Convert_Result convert_res const enum XML_Convert_Result convert_res
= XmlConvert(enc, &fromPtr, rawNameEnd, (ICHAR **)&toPtr, = XmlConvert(enc, &fromPtr, rawNameEnd, (ICHAR **)&toPtr,
(ICHAR *)tag->bufEnd - 1); (ICHAR *)tag->bufEnd - 1);
convLen = (int)(toPtr - (XML_Char *)tag->buf); convLen = (int)(toPtr - tag->buf.str);
if ((fromPtr >= rawNameEnd) if ((fromPtr >= rawNameEnd)
|| (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) { || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) {
tag->name.strLen = convLen; tag->name.strLen = convLen;
break; break;
} }
bufSize = (int)(tag->bufEnd - tag->buf) << 1; if (SIZE_MAX / 2 < (size_t)(tag->bufEnd - tag->buf.raw))
return XML_ERROR_NO_MEMORY;
const size_t bufSize = (size_t)(tag->bufEnd - tag->buf.raw) * 2;
{ {
char *temp = REALLOC(parser, tag->buf, bufSize); char *temp = REALLOC(parser, tag->buf.raw, bufSize);
if (temp == NULL) if (temp == NULL)
return XML_ERROR_NO_MEMORY; return XML_ERROR_NO_MEMORY;
tag->buf = temp; tag->buf.raw = temp;
tag->bufEnd = temp + bufSize; tag->bufEnd = temp + bufSize;
toPtr = (XML_Char *)temp + convLen; toPtr = (XML_Char *)temp + convLen;
} }
} }
} }
tag->name.str = (XML_Char *)tag->buf; tag->name.str = tag->buf.str;
*toPtr = XML_T('\0'); *toPtr = XML_T('\0');
result result
= storeAtts(parser, enc, s, &(tag->name), &(tag->bindings), account); = storeAtts(parser, enc, s, &(tag->name), &(tag->bindings), account);
@@ -3878,7 +3886,7 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr,
* from -Wtype-limits on platforms where * from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX #if UINT_MAX >= SIZE_MAX
if ((unsigned)parser->m_attsSize > (size_t)(-1) / sizeof(ATTRIBUTE)) { if ((unsigned)parser->m_attsSize > SIZE_MAX / sizeof(ATTRIBUTE)) {
parser->m_attsSize = oldAttsSize; parser->m_attsSize = oldAttsSize;
return XML_ERROR_NO_MEMORY; return XML_ERROR_NO_MEMORY;
} }
@@ -3897,7 +3905,7 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr,
* from -Wtype-limits on platforms where * from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
# if UINT_MAX >= SIZE_MAX # if UINT_MAX >= SIZE_MAX
if ((unsigned)parser->m_attsSize > (size_t)(-1) / sizeof(XML_AttrInfo)) { if ((unsigned)parser->m_attsSize > SIZE_MAX / sizeof(XML_AttrInfo)) {
parser->m_attsSize = oldAttsSize; parser->m_attsSize = oldAttsSize;
return XML_ERROR_NO_MEMORY; return XML_ERROR_NO_MEMORY;
} }
@@ -4073,7 +4081,7 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr,
* from -Wtype-limits on platforms where * from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX #if UINT_MAX >= SIZE_MAX
if (nsAttsSize > (size_t)(-1) / sizeof(NS_ATT)) { if (nsAttsSize > SIZE_MAX / sizeof(NS_ATT)) {
/* Restore actual size of memory in m_nsAtts */ /* Restore actual size of memory in m_nsAtts */
parser->m_nsAttsPower = oldNsAttsPower; parser->m_nsAttsPower = oldNsAttsPower;
return XML_ERROR_NO_MEMORY; return XML_ERROR_NO_MEMORY;
@@ -4256,7 +4264,7 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr,
* from -Wtype-limits on platforms where * from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX #if UINT_MAX >= SIZE_MAX
if ((unsigned)(n + EXPAND_SPARE) > (size_t)(-1) / sizeof(XML_Char)) { if ((unsigned)(n + EXPAND_SPARE) > SIZE_MAX / sizeof(XML_Char)) {
return XML_ERROR_NO_MEMORY; return XML_ERROR_NO_MEMORY;
} }
#endif #endif
@@ -4502,7 +4510,7 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
* from -Wtype-limits on platforms where * from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX #if UINT_MAX >= SIZE_MAX
if ((unsigned)(len + EXPAND_SPARE) > (size_t)(-1) / sizeof(XML_Char)) { if ((unsigned)(len + EXPAND_SPARE) > SIZE_MAX / sizeof(XML_Char)) {
return XML_ERROR_NO_MEMORY; return XML_ERROR_NO_MEMORY;
} }
#endif #endif
@@ -4529,7 +4537,7 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
* from -Wtype-limits on platforms where * from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX #if UINT_MAX >= SIZE_MAX
if ((unsigned)(len + EXPAND_SPARE) > (size_t)(-1) / sizeof(XML_Char)) { if ((unsigned)(len + EXPAND_SPARE) > SIZE_MAX / sizeof(XML_Char)) {
return XML_ERROR_NO_MEMORY; return XML_ERROR_NO_MEMORY;
} }
#endif #endif
@@ -5080,7 +5088,7 @@ entityValueInitProcessor(XML_Parser parser, const char *s, const char *end,
} }
/* If we get this token, we have the start of what might be a /* If we get this token, we have the start of what might be a
normal tag, but not a declaration (i.e. it doesn't begin with normal tag, but not a declaration (i.e. it doesn't begin with
"<!"). In a DTD context, that isn't legal. "<!" or "<?"). In a DTD context, that isn't legal.
*/ */
else if (tok == XML_TOK_INSTANCE_START) { else if (tok == XML_TOK_INSTANCE_START) {
*nextPtr = next; *nextPtr = next;
@@ -5169,6 +5177,15 @@ entityValueProcessor(XML_Parser parser, const char *s, const char *end,
/* found end of entity value - can store it now */ /* found end of entity value - can store it now */
return storeEntityValue(parser, enc, s, end, XML_ACCOUNT_DIRECT, NULL); return storeEntityValue(parser, enc, s, end, XML_ACCOUNT_DIRECT, NULL);
} }
/* If we get this token, we have the start of what might be a
normal tag, but not a declaration (i.e. it doesn't begin with
"<!" or "<?"). In a DTD context, that isn't legal.
*/
else if (tok == XML_TOK_INSTANCE_START) {
*nextPtr = next;
return XML_ERROR_SYNTAX;
}
start = next; start = next;
} }
} }
@@ -5920,15 +5937,18 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
* from -Wtype-limits on platforms where * from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX #if UINT_MAX >= SIZE_MAX
if (parser->m_groupSize > (size_t)(-1) / sizeof(int)) { if (parser->m_groupSize > SIZE_MAX / sizeof(int)) {
parser->m_groupSize /= 2;
return XML_ERROR_NO_MEMORY; return XML_ERROR_NO_MEMORY;
} }
#endif #endif
int *const new_scaff_index = REALLOC( int *const new_scaff_index = REALLOC(
parser, dtd->scaffIndex, parser->m_groupSize * sizeof(int)); parser, dtd->scaffIndex, parser->m_groupSize * sizeof(int));
if (new_scaff_index == NULL) if (new_scaff_index == NULL) {
parser->m_groupSize /= 2;
return XML_ERROR_NO_MEMORY; return XML_ERROR_NO_MEMORY;
}
dtd->scaffIndex = new_scaff_index; dtd->scaffIndex = new_scaff_index;
} }
} else { } else {
@@ -6780,7 +6800,14 @@ storeEntityValue(XML_Parser parser, const ENCODING *enc,
return XML_ERROR_NO_MEMORY; return XML_ERROR_NO_MEMORY;
} }
const char *next; const char *next = entityTextPtr;
/* Nothing to tokenize. */
if (entityTextPtr >= entityTextEnd) {
result = XML_ERROR_NONE;
goto endEntityValue;
}
for (;;) { for (;;) {
next next
= entityTextPtr; /* XmlEntityValueTok doesn't always set the last arg */ = entityTextPtr; /* XmlEntityValueTok doesn't always set the last arg */
@@ -7190,7 +7217,7 @@ defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, XML_Bool isCdata,
* from -Wtype-limits on platforms where * from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX #if UINT_MAX >= SIZE_MAX
if ((unsigned)count > (size_t)(-1) / sizeof(DEFAULT_ATTRIBUTE)) { if ((unsigned)count > SIZE_MAX / sizeof(DEFAULT_ATTRIBUTE)) {
return 0; return 0;
} }
#endif #endif
@@ -7430,16 +7457,24 @@ setContext(XML_Parser parser, const XML_Char *context) {
else { else {
if (! poolAppendChar(&parser->m_tempPool, XML_T('\0'))) if (! poolAppendChar(&parser->m_tempPool, XML_T('\0')))
return XML_FALSE; return XML_FALSE;
prefix const XML_Char *const prefixName = poolCopyStringNoFinish(
= (PREFIX *)lookup(parser, &dtd->prefixes, &dtd->pool, poolStart(&parser->m_tempPool));
poolStart(&parser->m_tempPool), sizeof(PREFIX)); if (! prefixName) {
return XML_FALSE;
}
prefix = (PREFIX *)lookup(parser, &dtd->prefixes, prefixName,
sizeof(PREFIX));
const bool prefixNameUsed = prefix && prefix->name == prefixName;
if (prefixNameUsed)
poolFinish(&dtd->pool);
else
poolDiscard(&dtd->pool);
if (! prefix) if (! prefix)
return XML_FALSE; return XML_FALSE;
if (prefix->name == poolStart(&parser->m_tempPool)) {
prefix->name = poolCopyString(&dtd->pool, prefix->name);
if (! prefix->name)
return XML_FALSE;
}
poolDiscard(&parser->m_tempPool); poolDiscard(&parser->m_tempPool);
} }
for (context = s + 1; *context != CONTEXT_SEP && *context != XML_T('\0'); for (context = s + 1; *context != CONTEXT_SEP && *context != XML_T('\0');
@@ -7666,8 +7701,7 @@ dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd,
* from -Wtype-limits on platforms where * from -Wtype-limits on platforms where
* sizeof(int) < sizeof(size_t), e.g. on x86_64. */ * sizeof(int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX #if UINT_MAX >= SIZE_MAX
if ((size_t)oldE->nDefaultAtts if ((size_t)oldE->nDefaultAtts > SIZE_MAX / sizeof(DEFAULT_ATTRIBUTE)) {
> ((size_t)(-1) / sizeof(DEFAULT_ATTRIBUTE))) {
return 0; return 0;
} }
#endif #endif
@@ -7869,7 +7903,7 @@ lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize) {
unsigned long newMask = (unsigned long)newSize - 1; unsigned long newMask = (unsigned long)newSize - 1;
/* Detect and prevent integer overflow */ /* Detect and prevent integer overflow */
if (newSize > (size_t)(-1) / sizeof(NAMED *)) { if (newSize > SIZE_MAX / sizeof(NAMED *)) {
return NULL; return NULL;
} }
@@ -8028,6 +8062,23 @@ poolCopyString(STRING_POOL *pool, const XML_Char *s) {
return s; return s;
} }
// A version of `poolCopyString` that does not call `poolFinish`
// and reverts any partial advancement upon failure.
static const XML_Char *FASTCALL
poolCopyStringNoFinish(STRING_POOL *pool, const XML_Char *s) {
const XML_Char *const original = s;
do {
if (! poolAppendChar(pool, *s)) {
// Revert any previously successful advancement
const ptrdiff_t advancedBy = s - original;
if (advancedBy > 0)
pool->ptr -= advancedBy;
return NULL;
}
} while (*s++);
return pool->start;
}
static const XML_Char * static const XML_Char *
poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n) { poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n) {
if (! pool->ptr && ! poolGrow(pool)) { if (! pool->ptr && ! poolGrow(pool)) {
@@ -8105,7 +8156,7 @@ poolBytesToAllocateFor(int blockSize) {
static XML_Bool FASTCALL static XML_Bool FASTCALL
poolGrow(STRING_POOL *pool) { poolGrow(STRING_POOL *pool) {
if (pool->freeBlocks) { if (pool->freeBlocks) {
if (pool->start == 0) { if (pool->start == NULL) {
pool->blocks = pool->freeBlocks; pool->blocks = pool->freeBlocks;
pool->freeBlocks = pool->freeBlocks->next; pool->freeBlocks = pool->freeBlocks->next;
pool->blocks->next = NULL; pool->blocks->next = NULL;
@@ -8217,7 +8268,7 @@ nextScaffoldPart(XML_Parser parser) {
* from -Wtype-limits on platforms where * from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX #if UINT_MAX >= SIZE_MAX
if (parser->m_groupSize > ((size_t)(-1) / sizeof(int))) { if (parser->m_groupSize > SIZE_MAX / sizeof(int)) {
return -1; return -1;
} }
#endif #endif
@@ -8244,7 +8295,7 @@ nextScaffoldPart(XML_Parser parser) {
* from -Wtype-limits on platforms where * from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX #if UINT_MAX >= SIZE_MAX
if (dtd->scaffSize > (size_t)(-1) / 2u / sizeof(CONTENT_SCAFFOLD)) { if (dtd->scaffSize > SIZE_MAX / 2u / sizeof(CONTENT_SCAFFOLD)) {
return -1; return -1;
} }
#endif #endif
@@ -8294,15 +8345,15 @@ build_model(XML_Parser parser) {
* from -Wtype-limits on platforms where * from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX #if UINT_MAX >= SIZE_MAX
if (dtd->scaffCount > (size_t)(-1) / sizeof(XML_Content)) { if (dtd->scaffCount > SIZE_MAX / sizeof(XML_Content)) {
return NULL; return NULL;
} }
if (dtd->contentStringLen > (size_t)(-1) / sizeof(XML_Char)) { if (dtd->contentStringLen > SIZE_MAX / sizeof(XML_Char)) {
return NULL; return NULL;
} }
#endif #endif
if (dtd->scaffCount * sizeof(XML_Content) if (dtd->scaffCount * sizeof(XML_Content)
> (size_t)(-1) - dtd->contentStringLen * sizeof(XML_Char)) { > SIZE_MAX - dtd->contentStringLen * sizeof(XML_Char)) {
return NULL; return NULL;
} }
+2 -2
View File
@@ -12,10 +12,11 @@
Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net> Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2002-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net> Copyright (c) 2002-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2005-2009 Steven Solie <steven@solie.ca> Copyright (c) 2005-2009 Steven Solie <steven@solie.ca>
Copyright (c) 2016-2023 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) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2019 David Loffredo <loffredo@steptools.com> Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
Copyright (c) 2021 Donghee Na <donghee.na@python.org> Copyright (c) 2021 Donghee Na <donghee.na@python.org>
Copyright (c) 2025 Alfonso Gregory <gfunni234@gmail.com>
Licensed under the MIT license: Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
@@ -46,7 +47,6 @@
# include "winconfig.h" # include "winconfig.h"
#endif #endif
#include "expat_external.h"
#include "internal.h" #include "internal.h"
#include "xmlrole.h" #include "xmlrole.h"
#include "ascii.h" #include "ascii.h"
+2 -2
View File
@@ -12,7 +12,7 @@
Copyright (c) 2002 Greg Stein <gstein@users.sourceforge.net> Copyright (c) 2002 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2002-2016 Karl Waclawek <karl@waclawek.net> Copyright (c) 2002-2016 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2005-2009 Steven Solie <steven@solie.ca> Copyright (c) 2005-2009 Steven Solie <steven@solie.ca>
Copyright (c) 2016-2024 Sebastian Pipping <sebastian@pipping.org> Copyright (c) 2016-2026 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2016 Pascal Cuoq <cuoq@trust-in-soft.com> Copyright (c) 2016 Pascal Cuoq <cuoq@trust-in-soft.com>
Copyright (c) 2016 Don Lewis <truckman@apache.org> Copyright (c) 2016 Don Lewis <truckman@apache.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk> Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
@@ -24,6 +24,7 @@
Copyright (c) 2022 Martin Ettl <ettl.martin78@googlemail.com> Copyright (c) 2022 Martin Ettl <ettl.martin78@googlemail.com>
Copyright (c) 2022 Sean McBride <sean@rogue-research.com> Copyright (c) 2022 Sean McBride <sean@rogue-research.com>
Copyright (c) 2023 Hanno Böck <hanno@gentoo.org> Copyright (c) 2023 Hanno Böck <hanno@gentoo.org>
Copyright (c) 2025 Alfonso Gregory <gfunni234@gmail.com>
Licensed under the MIT license: Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
@@ -56,7 +57,6 @@
# include "winconfig.h" # include "winconfig.h"
#endif #endif
#include "expat_external.h"
#include "internal.h" #include "internal.h"
#include "xmltok.h" #include "xmltok.h"
#include "nametab.h" #include "nametab.h"
+4 -3
View File
@@ -11,7 +11,8 @@
Copyright (c) 2002 Greg Stein <gstein@users.sourceforge.net> Copyright (c) 2002 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net> Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net> Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2017-2021 Sebastian Pipping <sebastian@pipping.org> Copyright (c) 2017-2026 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2025 Alfonso Gregory <gfunni234@gmail.com>
Licensed under the MIT license: Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
@@ -98,13 +99,13 @@ NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end) {
int i; int i;
XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1); XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);
if (ptr != end) if (ptr != end)
return 0; return NULL;
*p = 0; *p = 0;
if (streqci(buf, KW_UTF_16) && enc->minBytesPerChar == 2) if (streqci(buf, KW_UTF_16) && enc->minBytesPerChar == 2)
return enc; return enc;
i = getEncodingIndex(buf); i = getEncodingIndex(buf);
if (i == UNKNOWN_ENC) if (i == UNKNOWN_ENC)
return 0; return NULL;
return NS(encodings)[i]; return NS(encodings)[i];
} }