Skip to content

Commit dac733d

Browse files
committed
pocoproject#3849: Upgrade bundled libexpat to 2.5.0 [fixes CVE]
1 parent 4328fab commit dac733d

File tree

3 files changed

+35
-18
lines changed

3 files changed

+35
-18
lines changed

XML/include/Poco/XML/expat.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,8 +1054,8 @@ XML_SetBillionLaughsAttackProtectionActivationThreshold(
10541054
See http://semver.org.
10551055
*/
10561056
#define XML_MAJOR_VERSION 2
1057-
#define XML_MINOR_VERSION 4
1058-
#define XML_MICRO_VERSION 9
1057+
#define XML_MINOR_VERSION 5
1058+
#define XML_MICRO_VERSION 0
10591059

10601060
#ifdef __cplusplus
10611061
}

XML/src/xmlparse.cpp

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* fcb1a62fefa945567301146eb98e3ad3413e823a41c4378e84e8b6b6f308d824 (2.4.7+)
1+
/* 5ab094ffadd6edfc94c3eee53af44a86951f9f1f0933ada3114bbce2bfb02c99 (2.5.0+)
22
__ __ _
33
___\ \/ /_ __ __ _| |_
44
/ _ \\ /| '_ \ / _` | __|
@@ -35,6 +35,7 @@
3535
Copyright (c) 2021 Dong-hee Na <[email protected]>
3636
Copyright (c) 2022 Samanta Navarro <[email protected]>
3737
Copyright (c) 2022 Jeffrey Walton <[email protected]>
38+
Copyright (c) 2022 Jann Horn <[email protected]>
3839
Licensed under the MIT license:
3940
4041
Permission is hereby granted, free of charge, to any person obtaining
@@ -1088,6 +1089,14 @@ parserCreate(const XML_Char *encodingName,
10881089
parserInit(parser, encodingName);
10891090

10901091
if (encodingName && ! parser->m_protocolEncodingName) {
1092+
if (dtd) {
1093+
// We need to stop the upcoming call to XML_ParserFree from happily
1094+
// destroying parser->m_dtd because the DTD is shared with the parent
1095+
// parser and the only guard that keeps XML_ParserFree from destroying
1096+
// parser->m_dtd is parser->m_isParamEntity but it will be set to
1097+
// XML_TRUE only later in XML_ExternalEntityParserCreate (or not at all).
1098+
parser->m_dtd = NULL;
1099+
}
10911100
XML_ParserFree(parser);
10921101
return NULL;
10931102
}
@@ -3031,16 +3040,16 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
30313040
int len;
30323041
const char *rawName;
30333042
TAG *tag = parser->m_tagStack;
3034-
parser->m_tagStack = tag->parent;
3035-
tag->parent = parser->m_freeTagList;
3036-
parser->m_freeTagList = tag;
30373043
rawName = s + enc->minBytesPerChar * 2;
30383044
len = XmlNameLength(enc, rawName);
30393045
if (len != tag->rawNameLength
30403046
|| memcmp(tag->rawName, rawName, len) != 0) {
30413047
*eventPP = rawName;
30423048
return XML_ERROR_TAG_MISMATCH;
30433049
}
3050+
parser->m_tagStack = tag->parent;
3051+
tag->parent = parser->m_freeTagList;
3052+
parser->m_freeTagList = tag;
30443053
--parser->m_tagLevel;
30453054
if (parser->m_endElementHandler) {
30463055
const XML_Char *localPart;
@@ -4995,10 +5004,10 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
49955004
parser->m_handlerArg, parser->m_declElementType->name,
49965005
parser->m_declAttributeId->name, parser->m_declAttributeType, 0,
49975006
role == XML_ROLE_REQUIRED_ATTRIBUTE_VALUE);
4998-
poolClear(&parser->m_tempPool);
49995007
handleDefault = XML_FALSE;
50005008
}
50015009
}
5010+
poolClear(&parser->m_tempPool);
50025011
break;
50035012
case XML_ROLE_DEFAULT_ATTRIBUTE_VALUE:
50045013
case XML_ROLE_FIXED_ATTRIBUTE_VALUE:
@@ -5406,7 +5415,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
54065415
*
54075416
* If 'standalone' is false, the DTD must have no
54085417
* parameter entities or we wouldn't have passed the outer
5409-
* 'if' statement. That measn the only entity in the hash
5418+
* 'if' statement. That means the only entity in the hash
54105419
* table is the external subset name "#" which cannot be
54115420
* given as a parameter entity name in XML syntax, so the
54125421
* lookup must have returned NULL and we don't even reach
@@ -5818,19 +5827,27 @@ internalEntityProcessor(XML_Parser parser, const char *s, const char *end,
58185827

58195828
if (result != XML_ERROR_NONE)
58205829
return result;
5821-
else if (textEnd != next
5822-
&& parser->m_parsingStatus.parsing == XML_SUSPENDED) {
5830+
5831+
if (textEnd != next && parser->m_parsingStatus.parsing == XML_SUSPENDED) {
58235832
entity->processed = (int)(next - (const char *)entity->textPtr);
58245833
return result;
5825-
} else {
5834+
}
5835+
58265836
#ifdef XML_DTD
5827-
entityTrackingOnClose(parser, entity, __LINE__);
5837+
entityTrackingOnClose(parser, entity, __LINE__);
58285838
#endif
5829-
entity->open = XML_FALSE;
5830-
parser->m_openInternalEntities = openEntity->next;
5831-
/* put openEntity back in list of free instances */
5832-
openEntity->next = parser->m_freeInternalEntities;
5833-
parser->m_freeInternalEntities = openEntity;
5839+
entity->open = XML_FALSE;
5840+
parser->m_openInternalEntities = openEntity->next;
5841+
/* put openEntity back in list of free instances */
5842+
openEntity->next = parser->m_freeInternalEntities;
5843+
parser->m_freeInternalEntities = openEntity;
5844+
5845+
// If there are more open entities we want to stop right here and have the
5846+
// upcoming call to XML_ResumeParser continue with entity content, or it would
5847+
// be ignored altogether.
5848+
if (parser->m_openInternalEntities != NULL
5849+
&& parser->m_parsingStatus.parsing == XML_SUSPENDED) {
5850+
return XML_ERROR_NONE;
58345851
}
58355852

58365853
#ifdef XML_DTD

XML/src/xmltok_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ enum {
4545
BT_LF, /* line feed = "\n" */
4646
BT_GT, /* greater than = ">" */
4747
BT_QUOT, /* quotation character = "\"" */
48-
BT_APOS, /* aposthrophe = "'" */
48+
BT_APOS, /* apostrophe = "'" */
4949
BT_EQUALS, /* equal sign = "=" */
5050
BT_QUEST, /* question mark = "?" */
5151
BT_EXCL, /* exclamation mark = "!" */

0 commit comments

Comments
 (0)