Skip to content

Commit b582d52

Browse files
authored
[3.11] gh-123678: Upgrade libexpat 2.6.3 (#123709)
(cherry picked from commit e6fe0ac)
1 parent 522799a commit b582d52

File tree

4 files changed

+36
-15
lines changed

4 files changed

+36
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Upgrade libexpat to 2.6.3

Modules/expat/expat.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled);
10661066
*/
10671067
#define XML_MAJOR_VERSION 2
10681068
#define XML_MINOR_VERSION 6
1069-
#define XML_MICRO_VERSION 2
1069+
#define XML_MICRO_VERSION 3
10701070

10711071
#ifdef __cplusplus
10721072
}

Modules/expat/siphash.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@
126126
| ((uint64_t)((p)[4]) << 32) | ((uint64_t)((p)[5]) << 40) \
127127
| ((uint64_t)((p)[6]) << 48) | ((uint64_t)((p)[7]) << 56))
128128

129-
#define SIPHASH_INITIALIZER \
130-
{ 0, 0, 0, 0, {0}, 0, 0 }
129+
#define SIPHASH_INITIALIZER {0, 0, 0, 0, {0}, 0, 0}
131130

132131
struct siphash {
133132
uint64_t v0, v1, v2, v3;

Modules/expat/xmlparse.c

+33-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* 2a14271ad4d35e82bde8ba210b4edb7998794bcbae54deab114046a300f9639a (2.6.2+)
1+
/* ba4cdf9bdb534f355a9def4c9e25d20ee8e72f95b0a4d930be52e563f5080196 (2.6.3+)
22
__ __ _
33
___\ \/ /_ __ __ _| |_
44
/ _ \\ /| '_ \ / _` | __|
@@ -39,6 +39,7 @@
3939
Copyright (c) 2022 Sean McBride <[email protected]>
4040
Copyright (c) 2023 Owain Davies <[email protected]>
4141
Copyright (c) 2023-2024 Sony Corporation / Snild Dolkow <[email protected]>
42+
Copyright (c) 2024 Berkay Eren Ürün <[email protected]>
4243
Licensed under the MIT license:
4344
4445
Permission is hereby granted, free of charge, to any person obtaining
@@ -294,7 +295,7 @@ typedef struct {
294295
The name of the element is stored in both the document and API
295296
encodings. The memory buffer 'buf' is a separately-allocated
296297
memory area which stores the name. During the XML_Parse()/
297-
XMLParseBuffer() when the element is open, the memory for the 'raw'
298+
XML_ParseBuffer() when the element is open, the memory for the 'raw'
298299
version of the name (in the document encoding) is shared with the
299300
document buffer. If the element is open across calls to
300301
XML_Parse()/XML_ParseBuffer(), the buffer is re-allocated to
@@ -2038,6 +2039,12 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal) {
20382039

20392040
if (parser == NULL)
20402041
return XML_STATUS_ERROR;
2042+
2043+
if (len < 0) {
2044+
parser->m_errorCode = XML_ERROR_INVALID_ARGUMENT;
2045+
return XML_STATUS_ERROR;
2046+
}
2047+
20412048
switch (parser->m_parsingStatus.parsing) {
20422049
case XML_SUSPENDED:
20432050
parser->m_errorCode = XML_ERROR_SUSPENDED;
@@ -5846,18 +5853,17 @@ processInternalEntity(XML_Parser parser, ENTITY *entity, XML_Bool betweenDecl) {
58465853
/* Set a safe default value in case 'next' does not get set */
58475854
next = textStart;
58485855

5849-
#ifdef XML_DTD
58505856
if (entity->is_param) {
58515857
int tok
58525858
= XmlPrologTok(parser->m_internalEncoding, textStart, textEnd, &next);
58535859
result = doProlog(parser, parser->m_internalEncoding, textStart, textEnd,
58545860
tok, next, &next, XML_FALSE, XML_FALSE,
58555861
XML_ACCOUNT_ENTITY_EXPANSION);
5856-
} else
5857-
#endif /* XML_DTD */
5862+
} else {
58585863
result = doContent(parser, parser->m_tagLevel, parser->m_internalEncoding,
58595864
textStart, textEnd, &next, XML_FALSE,
58605865
XML_ACCOUNT_ENTITY_EXPANSION);
5866+
}
58615867

58625868
if (result == XML_ERROR_NONE) {
58635869
if (textEnd != next && parser->m_parsingStatus.parsing == XML_SUSPENDED) {
@@ -5894,18 +5900,17 @@ internalEntityProcessor(XML_Parser parser, const char *s, const char *end,
58945900
/* Set a safe default value in case 'next' does not get set */
58955901
next = textStart;
58965902

5897-
#ifdef XML_DTD
58985903
if (entity->is_param) {
58995904
int tok
59005905
= XmlPrologTok(parser->m_internalEncoding, textStart, textEnd, &next);
59015906
result = doProlog(parser, parser->m_internalEncoding, textStart, textEnd,
59025907
tok, next, &next, XML_FALSE, XML_TRUE,
59035908
XML_ACCOUNT_ENTITY_EXPANSION);
5904-
} else
5905-
#endif /* XML_DTD */
5909+
} else {
59065910
result = doContent(parser, openEntity->startTagLevel,
59075911
parser->m_internalEncoding, textStart, textEnd, &next,
59085912
XML_FALSE, XML_ACCOUNT_ENTITY_EXPANSION);
5913+
}
59095914

59105915
if (result != XML_ERROR_NONE)
59115916
return result;
@@ -5932,17 +5937,14 @@ internalEntityProcessor(XML_Parser parser, const char *s, const char *end,
59325937
return XML_ERROR_NONE;
59335938
}
59345939

5935-
#ifdef XML_DTD
59365940
if (entity->is_param) {
59375941
int tok;
59385942
parser->m_processor = prologProcessor;
59395943
tok = XmlPrologTok(parser->m_encoding, s, end, &next);
59405944
return doProlog(parser, parser->m_encoding, s, end, tok, next, nextPtr,
59415945
(XML_Bool)! parser->m_parsingStatus.finalBuffer, XML_TRUE,
59425946
XML_ACCOUNT_DIRECT);
5943-
} else
5944-
#endif /* XML_DTD */
5945-
{
5947+
} else {
59465948
parser->m_processor = contentProcessor;
59475949
/* see externalEntityContentProcessor vs contentProcessor */
59485950
result = doContent(parser, parser->m_parentParser ? 1 : 0,
@@ -7016,6 +7018,16 @@ dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd,
70167018
if (! newE)
70177019
return 0;
70187020
if (oldE->nDefaultAtts) {
7021+
/* Detect and prevent integer overflow.
7022+
* The preprocessor guard addresses the "always false" warning
7023+
* from -Wtype-limits on platforms where
7024+
* sizeof(int) < sizeof(size_t), e.g. on x86_64. */
7025+
#if UINT_MAX >= SIZE_MAX
7026+
if ((size_t)oldE->nDefaultAtts
7027+
> ((size_t)(-1) / sizeof(DEFAULT_ATTRIBUTE))) {
7028+
return 0;
7029+
}
7030+
#endif
70197031
newE->defaultAtts
70207032
= ms->malloc_fcn(oldE->nDefaultAtts * sizeof(DEFAULT_ATTRIBUTE));
70217033
if (! newE->defaultAtts) {
@@ -7558,6 +7570,15 @@ nextScaffoldPart(XML_Parser parser) {
75587570
int next;
75597571

75607572
if (! dtd->scaffIndex) {
7573+
/* Detect and prevent integer overflow.
7574+
* The preprocessor guard addresses the "always false" warning
7575+
* from -Wtype-limits on platforms where
7576+
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
7577+
#if UINT_MAX >= SIZE_MAX
7578+
if (parser->m_groupSize > ((size_t)(-1) / sizeof(int))) {
7579+
return -1;
7580+
}
7581+
#endif
75617582
dtd->scaffIndex = (int *)MALLOC(parser, parser->m_groupSize * sizeof(int));
75627583
if (! dtd->scaffIndex)
75637584
return -1;

0 commit comments

Comments
 (0)