Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 196d7db

Browse files
committed
upgrade expt to 2.1.1 (closes #26556)
1 parent 46b32f3 commit 196d7db

4 files changed

Lines changed: 26 additions & 6 deletions

File tree

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Core and Builtins
1919
Library
2020
-------
2121

22+
- Issue #26556: Update expat to 2.1.1, fixes CVE-2015-1283.
23+
2224
- Fix TLS stripping vulnerability in smptlib, CVE-2016-0772. Reported by Team
2325
Oststrom
2426

Modules/expat/expat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ XML_GetFeatureList(void);
10401040
*/
10411041
#define XML_MAJOR_VERSION 2
10421042
#define XML_MINOR_VERSION 1
1043-
#define XML_MICRO_VERSION 0
1043+
#define XML_MICRO_VERSION 1
10441044

10451045
#ifdef __cplusplus
10461046
}

Modules/expat/xmlparse.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,7 +1550,7 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
15501550
else if (bufferPtr == bufferEnd) {
15511551
const char *end;
15521552
int nLeftOver;
1553-
enum XML_Error result;
1553+
enum XML_Status result;
15541554
parseEndByteIndex += len;
15551555
positionPtr = s;
15561556
ps_finalBuffer = (XML_Bool)isFinal;
@@ -1678,6 +1678,10 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal)
16781678
void * XMLCALL
16791679
XML_GetBuffer(XML_Parser parser, int len)
16801680
{
1681+
if (len < 0) {
1682+
errorCode = XML_ERROR_NO_MEMORY;
1683+
return NULL;
1684+
}
16811685
switch (ps_parsing) {
16821686
case XML_SUSPENDED:
16831687
errorCode = XML_ERROR_SUSPENDED;
@@ -1689,10 +1693,16 @@ XML_GetBuffer(XML_Parser parser, int len)
16891693
}
16901694

16911695
if (len > bufferLim - bufferEnd) {
1692-
/* FIXME avoid integer overflow */
1696+
#ifdef XML_CONTEXT_BYTES
1697+
int keep;
1698+
#endif
16931699
int neededSize = len + (int)(bufferEnd - bufferPtr);
1700+
if (neededSize < 0) {
1701+
errorCode = XML_ERROR_NO_MEMORY;
1702+
return NULL;
1703+
}
16941704
#ifdef XML_CONTEXT_BYTES
1695-
int keep = (int)(bufferPtr - buffer);
1705+
keep = (int)(bufferPtr - buffer);
16961706

16971707
if (keep > XML_CONTEXT_BYTES)
16981708
keep = XML_CONTEXT_BYTES;
@@ -1719,7 +1729,11 @@ XML_GetBuffer(XML_Parser parser, int len)
17191729
bufferSize = INIT_BUFFER_SIZE;
17201730
do {
17211731
bufferSize *= 2;
1722-
} while (bufferSize < neededSize);
1732+
} while (bufferSize < neededSize && bufferSize > 0);
1733+
if (bufferSize <= 0) {
1734+
errorCode = XML_ERROR_NO_MEMORY;
1735+
return NULL;
1736+
}
17231737
newBuf = (char *)MALLOC(bufferSize);
17241738
if (newBuf == 0) {
17251739
errorCode = XML_ERROR_NO_MEMORY;
@@ -2911,6 +2925,8 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
29112925
unsigned long uriHash = hash_secret_salt;
29122926
((XML_Char *)s)[-1] = 0; /* clear flag */
29132927
id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, s, 0);
2928+
if (!id || !id->prefix)
2929+
return XML_ERROR_NO_MEMORY;
29142930
b = id->prefix->binding;
29152931
if (!b)
29162932
return XML_ERROR_UNBOUND_PREFIX;
@@ -5475,6 +5491,8 @@ getAttributeId(XML_Parser parser, const ENCODING *enc,
54755491
return NULL;
54765492
id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&dtd->pool),
54775493
sizeof(PREFIX));
5494+
if (!id->prefix)
5495+
return NULL;
54785496
if (id->prefix->name == poolStart(&dtd->pool))
54795497
poolFinish(&dtd->pool);
54805498
else

Modules/expat/xmltok.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,7 @@ initScan(const ENCODING * const *encodingTable,
15841584
if (ptr[0] == '\0') {
15851585
/* 0 isn't a legal data character. Furthermore a document
15861586
entity can only start with ASCII characters. So the only
1587-
way this can fail to be big-endian UTF-16 is if it is an
1587+
way this can fail to be big-endian UTF-16 if it it's an
15881588
external parsed general entity that's labelled as
15891589
UTF-16LE.
15901590
*/

0 commit comments

Comments
 (0)