Skip to content

Commit d9920c1

Browse files
committed
upgrade vendored expat to 2.4.7
1 parent 28b0ed3 commit d9920c1

File tree

19 files changed

+1860
-252
lines changed

19 files changed

+1860
-252
lines changed

Modules/expat/ascii.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
\___/_/\_\ .__/ \__,_|\__|
77
|_| XML parser
88
9-
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
10-
Copyright (c) 2000-2017 Expat development team
9+
Copyright (c) 1999-2000 Thai Open Source Software Center Ltd
10+
Copyright (c) 2000 Clark Cooper <[email protected]>
11+
Copyright (c) 2002 Fred L. Drake, Jr. <[email protected]>
12+
Copyright (c) 2007 Karl Waclawek <[email protected]>
13+
Copyright (c) 2017 Sebastian Pipping <[email protected]>
1114
Licensed under the MIT license:
1215
1316
Permission is hereby granted, free of charge, to any person obtaining

Modules/expat/asciitab.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
|_| XML parser
88
99
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
10-
Copyright (c) 2000-2017 Expat development team
10+
Copyright (c) 2000 Clark Cooper <[email protected]>
11+
Copyright (c) 2002 Fred L. Drake, Jr. <[email protected]>
12+
Copyright (c) 2017 Sebastian Pipping <[email protected]>
1113
Licensed under the MIT license:
1214
1315
Permission is hereby granted, free of charge, to any person obtaining

Modules/expat/expat.h

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@
77
|_| XML parser
88
99
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
10-
Copyright (c) 2000-2017 Expat development team
10+
Copyright (c) 2000 Clark Cooper <[email protected]>
11+
Copyright (c) 2000-2005 Fred L. Drake, Jr. <[email protected]>
12+
Copyright (c) 2001-2002 Greg Stein <[email protected]>
13+
Copyright (c) 2002-2016 Karl Waclawek <[email protected]>
14+
Copyright (c) 2016-2022 Sebastian Pipping <[email protected]>
15+
Copyright (c) 2016 Cristian Rodríguez <[email protected]>
16+
Copyright (c) 2016 Thomas Beutlich <[email protected]>
17+
Copyright (c) 2017 Rhodri James <[email protected]>
18+
Copyright (c) 2022 Thijs Schreijer <[email protected]>
1119
Licensed under the MIT license:
1220
1321
Permission is hereby granted, free of charge, to any person obtaining
@@ -115,7 +123,11 @@ enum XML_Error {
115123
XML_ERROR_RESERVED_PREFIX_XMLNS,
116124
XML_ERROR_RESERVED_NAMESPACE_URI,
117125
/* Added in 2.2.1. */
118-
XML_ERROR_INVALID_ARGUMENT
126+
XML_ERROR_INVALID_ARGUMENT,
127+
/* Added in 2.3.0. */
128+
XML_ERROR_NO_BUFFER,
129+
/* Added in 2.4.0. */
130+
XML_ERROR_AMPLIFICATION_LIMIT_BREACH
119131
};
120132

121133
enum XML_Content_Type {
@@ -163,8 +175,10 @@ struct XML_cp {
163175
};
164176

165177
/* This is called for an element declaration. See above for
166-
description of the model argument. It's the caller's responsibility
167-
to free model when finished with it.
178+
description of the model argument. It's the user code's responsibility
179+
to free model when finished with it. See XML_FreeContentModel.
180+
There is no need to free the model from the handler, it can be kept
181+
around and freed at a later stage.
168182
*/
169183
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData,
170184
const XML_Char *name,
@@ -226,6 +240,17 @@ XML_ParserCreate(const XML_Char *encoding);
226240
and the local part will be concatenated without any separator.
227241
It is a programming error to use the separator '\0' with namespace
228242
triplets (see XML_SetReturnNSTriplet).
243+
If a namespace separator is chosen that can be part of a URI or
244+
part of an XML name, splitting an expanded name back into its
245+
1, 2 or 3 original parts on application level in the element handler
246+
may end up vulnerable, so these are advised against; sane choices for
247+
a namespace separator are e.g. '\n' (line feed) and '|' (pipe).
248+
249+
Note that Expat does not validate namespace URIs (beyond encoding)
250+
against RFC 3986 today (and is not required to do so with regard to
251+
the XML 1.0 namespaces specification) but it may start doing that
252+
in future releases. Before that, an application using Expat must
253+
be ready to receive namespace URIs containing non-URI characters.
229254
*/
230255
XMLPARSEAPI(XML_Parser)
231256
XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
@@ -306,7 +331,7 @@ typedef void(XMLCALL *XML_StartDoctypeDeclHandler)(void *userData,
306331
const XML_Char *pubid,
307332
int has_internal_subset);
308333

309-
/* This is called for the start of the DOCTYPE declaration when the
334+
/* This is called for the end of the DOCTYPE declaration when the
310335
closing > is encountered, but after processing any external
311336
subset.
312337
*/
@@ -318,7 +343,7 @@ typedef void(XMLCALL *XML_EndDoctypeDeclHandler)(void *userData);
318343
319344
For internal entities (<!ENTITY foo "bar">), value will
320345
be non-NULL and systemId, publicID, and notationName will be NULL.
321-
The value string is NOT nul-terminated; the length is provided in
346+
The value string is NOT null-terminated; the length is provided in
322347
the value_length argument. Since it is legal to have zero-length
323348
values, do not use this argument to test for internal entities.
324349
@@ -513,7 +538,7 @@ typedef struct {
513538
Otherwise it must return XML_STATUS_ERROR.
514539
515540
If info does not describe a suitable encoding, then the parser will
516-
return an XML_UNKNOWN_ENCODING error.
541+
return an XML_ERROR_UNKNOWN_ENCODING error.
517542
*/
518543
typedef int(XMLCALL *XML_UnknownEncodingHandler)(void *encodingHandlerData,
519544
const XML_Char *name,
@@ -707,7 +732,7 @@ XML_GetBase(XML_Parser parser);
707732
/* Returns the number of the attribute/value pairs passed in last call
708733
to the XML_StartElementHandler that were specified in the start-tag
709734
rather than defaulted. Each attribute/value pair counts as 2; thus
710-
this correspondds to an index into the atts array passed to the
735+
this corresponds to an index into the atts array passed to the
711736
XML_StartElementHandler. Returns -1 if parser == NULL.
712737
*/
713738
XMLPARSEAPI(int)
@@ -716,7 +741,7 @@ XML_GetSpecifiedAttributeCount(XML_Parser parser);
716741
/* Returns the index of the ID attribute passed in the last call to
717742
XML_StartElementHandler, or -1 if there is no ID attribute or
718743
parser == NULL. Each attribute/value pair counts as 2; thus this
719-
correspondds to an index into the atts array passed to the
744+
corresponds to an index into the atts array passed to the
720745
XML_StartElementHandler.
721746
*/
722747
XMLPARSEAPI(int)
@@ -997,7 +1022,10 @@ enum XML_FeatureEnum {
9971022
XML_FEATURE_SIZEOF_XML_LCHAR,
9981023
XML_FEATURE_NS,
9991024
XML_FEATURE_LARGE_SIZE,
1000-
XML_FEATURE_ATTR_INFO
1025+
XML_FEATURE_ATTR_INFO,
1026+
/* Added in Expat 2.4.0. */
1027+
XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT,
1028+
XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT
10011029
/* Additional features must be added to the end of this enum. */
10021030
};
10031031

@@ -1010,12 +1038,24 @@ typedef struct {
10101038
XMLPARSEAPI(const XML_Feature *)
10111039
XML_GetFeatureList(void);
10121040

1041+
#ifdef XML_DTD
1042+
/* Added in Expat 2.4.0. */
1043+
XMLPARSEAPI(XML_Bool)
1044+
XML_SetBillionLaughsAttackProtectionMaximumAmplification(
1045+
XML_Parser parser, float maximumAmplificationFactor);
1046+
1047+
/* Added in Expat 2.4.0. */
1048+
XMLPARSEAPI(XML_Bool)
1049+
XML_SetBillionLaughsAttackProtectionActivationThreshold(
1050+
XML_Parser parser, unsigned long long activationThresholdBytes);
1051+
#endif
1052+
10131053
/* Expat follows the semantic versioning convention.
10141054
See http://semver.org.
10151055
*/
10161056
#define XML_MAJOR_VERSION 2
1017-
#define XML_MINOR_VERSION 2
1018-
#define XML_MICRO_VERSION 8
1057+
#define XML_MINOR_VERSION 4
1058+
#define XML_MICRO_VERSION 7
10191059

10201060
#ifdef __cplusplus
10211061
}

Modules/expat/expat_external.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
|_| XML parser
88
99
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
10-
Copyright (c) 2000-2017 Expat development team
10+
Copyright (c) 2000 Clark Cooper <[email protected]>
11+
Copyright (c) 2000-2004 Fred L. Drake, Jr. <[email protected]>
12+
Copyright (c) 2001-2002 Greg Stein <[email protected]>
13+
Copyright (c) 2002-2006 Karl Waclawek <[email protected]>
14+
Copyright (c) 2016 Cristian Rodríguez <[email protected]>
15+
Copyright (c) 2016-2019 Sebastian Pipping <[email protected]>
16+
Copyright (c) 2017 Rhodri James <[email protected]>
17+
Copyright (c) 2018 Yury Gribov <[email protected]>
1118
Licensed under the MIT license:
1219
1320
Permission is hereby granted, free of charge, to any person obtaining

Modules/expat/iasciitab.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
|_| XML parser
88
99
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
10-
Copyright (c) 2000-2017 Expat development team
10+
Copyright (c) 2000 Clark Cooper <[email protected]>
11+
Copyright (c) 2002 Fred L. Drake, Jr. <[email protected]>
12+
Copyright (c) 2017 Sebastian Pipping <[email protected]>
1113
Licensed under the MIT license:
1214
1315
Permission is hereby granted, free of charge, to any person obtaining

Modules/expat/internal.h

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@
2525
\___/_/\_\ .__/ \__,_|\__|
2626
|_| XML parser
2727
28-
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
29-
Copyright (c) 2000-2017 Expat development team
28+
Copyright (c) 2002-2003 Fred L. Drake, Jr. <[email protected]>
29+
Copyright (c) 2002-2006 Karl Waclawek <[email protected]>
30+
Copyright (c) 2003 Greg Stein <[email protected]>
31+
Copyright (c) 2016-2021 Sebastian Pipping <[email protected]>
32+
Copyright (c) 2018 Yury Gribov <[email protected]>
33+
Copyright (c) 2019 David Loffredo <[email protected]>
3034
Licensed under the MIT license:
3135
3236
Permission is hereby granted, free of charge, to any person obtaining
@@ -101,22 +105,58 @@
101105
# endif
102106
#endif
103107

108+
#include <limits.h> // ULONG_MAX
109+
110+
#if defined(_WIN32) && ! defined(__USE_MINGW_ANSI_STDIO)
111+
# define EXPAT_FMT_ULL(midpart) "%" midpart "I64u"
112+
# if defined(_WIN64) // Note: modifiers "td" and "zu" do not work for MinGW
113+
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "I64d"
114+
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "I64u"
115+
# else
116+
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d"
117+
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u"
118+
# endif
119+
#else
120+
# define EXPAT_FMT_ULL(midpart) "%" midpart "llu"
121+
# if ! defined(ULONG_MAX)
122+
# error Compiler did not define ULONG_MAX for us
123+
# elif ULONG_MAX == 18446744073709551615u // 2^64-1
124+
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld"
125+
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "lu"
126+
# else
127+
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d"
128+
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u"
129+
# endif
130+
#endif
131+
104132
#ifndef UNUSED_P
105133
# define UNUSED_P(p) (void)p
106134
#endif
107135

136+
/* NOTE BEGIN If you ever patch these defaults to greater values
137+
for non-attack XML payload in your environment,
138+
please file a bug report with libexpat. Thank you!
139+
*/
140+
#define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT \
141+
100.0f
142+
#define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT \
143+
8388608 // 8 MiB, 2^23
144+
/* NOTE END */
145+
146+
#include "expat.h" // so we can use type XML_Parser below
147+
108148
#ifdef __cplusplus
109149
extern "C" {
110150
#endif
111151

112-
#ifdef XML_ENABLE_VISIBILITY
113-
# if XML_ENABLE_VISIBILITY
114-
__attribute__((visibility("default")))
115-
# endif
152+
void _INTERNAL_trim_to_complete_utf8_characters(const char *from,
153+
const char **fromLimRef);
154+
155+
#if defined(XML_DTD)
156+
unsigned long long testingAccountingGetCountBytesDirect(XML_Parser parser);
157+
unsigned long long testingAccountingGetCountBytesIndirect(XML_Parser parser);
158+
const char *unsignedCharToPrintable(unsigned char c);
116159
#endif
117-
void
118-
_INTERNAL_trim_to_complete_utf8_characters(const char *from,
119-
const char **fromLimRef);
120160

121161
#ifdef __cplusplus
122162
}

Modules/expat/latin1tab.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
|_| XML parser
88
99
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
10-
Copyright (c) 2000-2017 Expat development team
10+
Copyright (c) 2000 Clark Cooper <[email protected]>
11+
Copyright (c) 2002 Fred L. Drake, Jr. <[email protected]>
12+
Copyright (c) 2017 Sebastian Pipping <[email protected]>
1113
Licensed under the MIT license:
1214
1315
Permission is hereby granted, free of charge, to any person obtaining

Modules/expat/nametab.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
\___/_/\_\ .__/ \__,_|\__|
77
|_| XML parser
88
9-
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
10-
Copyright (c) 2000-2017 Expat development team
9+
Copyright (c) 2000 Clark Cooper <[email protected]>
10+
Copyright (c) 2017 Sebastian Pipping <[email protected]>
1111
Licensed under the MIT license:
1212
1313
Permission is hereby granted, free of charge, to any person obtaining

Modules/expat/siphash.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
* --------------------------------------------------------------------------
1212
* HISTORY:
1313
*
14+
* 2020-10-03 (Sebastian Pipping)
15+
* - Drop support for Visual Studio 9.0/2008 and earlier
16+
*
1417
* 2019-08-03 (Sebastian Pipping)
1518
* - Mark part of sip24_valid as to be excluded from clang-format
1619
* - Re-format code using clang-format 9
@@ -96,15 +99,7 @@
9699
#define SIPHASH_H
97100

98101
#include <stddef.h> /* size_t */
99-
100-
#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1600)
101-
/* For vs2003/7.1 up to vs2008/9.0; _MSC_VER 1600 is vs2010/10.0 */
102-
typedef unsigned __int8 uint8_t;
103-
typedef unsigned __int32 uint32_t;
104-
typedef unsigned __int64 uint64_t;
105-
#else
106-
# include <stdint.h> /* uint64_t uint32_t uint8_t */
107-
#endif
102+
#include <stdint.h> /* uint64_t uint32_t uint8_t */
108103

109104
/*
110105
* Workaround to not require a C++11 compiler for using ULL suffix

Modules/expat/utf8tab.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
|_| XML parser
88
99
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
10-
Copyright (c) 2000-2017 Expat development team
10+
Copyright (c) 2000 Clark Cooper <[email protected]>
11+
Copyright (c) 2002 Fred L. Drake, Jr. <[email protected]>
12+
Copyright (c) 2017 Sebastian Pipping <[email protected]>
1113
Licensed under the MIT license:
1214
1315
Permission is hereby granted, free of charge, to any person obtaining

0 commit comments

Comments
 (0)