summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Pipping <sebastian@pipping.org>2021-04-24 21:13:24 +0200
committerSebastian Pipping <sebastian@pipping.org>2021-04-26 14:18:00 +0200
commited36812db2017e8a68eb7825ecd8dd2bc89cd2e5 (patch)
treec7069af8a18fa098dd04423e9dc6fb16b1e80927
parent3b1b81f0284feb9e02387680e31293c363221161 (diff)
downloadlibexpat-git-ed36812db2017e8a68eb7825ecd8dd2bc89cd2e5.tar.gz
lib: Fix macro IS_INVALID_CHAR (for UTF-16 with macro XML_MIN_SIZE defined)issue-332-drop-clang-asan-plus-min-size-workaround
What happens is that with macro XML_MIN_SIZE defined, for UTF-16 macro IS_INVALID_CHAR was being set to .. > #define IS_INVALID_CHAR(enc, p, n) (AS_NORMAL_ENCODING(enc)->isInvalid##n(enc, p)) .. which calls NULL pointers in .isInvalid{2,3,4} at runtime. For UTF-16 we actually need what xmltok_impl.c does for macro IS_INVALID_CHAR when it has not yet been defined: > # ifndef IS_INVALID_CHAR > # define IS_INVALID_CHAR(enc, ptr, n) (0) > # endif So the fix is a combination of these two: - Use .isInvalid{2,3,4} where needed and available and - return 0/false for UTF-16 where .isInvalid{2,3,4} are NULL.
-rw-r--r--expat/Changes8
-rw-r--r--expat/lib/xmltok.c10
2 files changed, 16 insertions, 2 deletions
diff --git a/expat/Changes b/expat/Changes
index 40b716d9..69c39f37 100644
--- a/expat/Changes
+++ b/expat/Changes
@@ -3,12 +3,20 @@ NOTE: We are looking for help with a few things:
If you can help, please get in touch. Thanks!
Release X.X.X XXX XXXXX XX XXXX
+ 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.
+
Other changes:
#457 Unexpose symbol _INTERNAL_trim_to_complete_utf8_characters
#458 #459 CMake: Support absolute paths for both CMAKE_INSTALL_LIBDIR
and CMAKE_INSTALL_INCLUDEDIR
#468 #469 xmlwf: Improve help output and the xmlwf man page
+ Special thanks to:
+ Dimitry Andric
+
Release 2.3.0 Thu March 25 2021
Bug fixes:
#438 When calling XML_ParseBuffer without a prior successful call to
diff --git a/expat/lib/xmltok.c b/expat/lib/xmltok.c
index d9474240..7759ffb6 100644
--- a/expat/lib/xmltok.c
+++ b/expat/lib/xmltok.c
@@ -259,8 +259,14 @@ sb_byteToAscii(const ENCODING *enc, const char *p) {
#define IS_NAME_CHAR(enc, p, n) (AS_NORMAL_ENCODING(enc)->isName##n(enc, p))
#define IS_NMSTRT_CHAR(enc, p, n) (AS_NORMAL_ENCODING(enc)->isNmstrt##n(enc, p))
-#define IS_INVALID_CHAR(enc, p, n) \
- (AS_NORMAL_ENCODING(enc)->isInvalid##n(enc, p))
+#ifdef XML_MIN_SIZE
+# define IS_INVALID_CHAR(enc, p, n) \
+ (AS_NORMAL_ENCODING(enc)->isInvalid##n \
+ && AS_NORMAL_ENCODING(enc)->isInvalid##n(enc, p))
+#else
+# define IS_INVALID_CHAR(enc, p, n) \
+ (AS_NORMAL_ENCODING(enc)->isInvalid##n(enc, p))
+#endif
#ifdef XML_MIN_SIZE
# define IS_NAME_CHAR_MINBPC(enc, p) \