mirror of
https://github.com/libexpat/libexpat.git
synced 2025-04-15 00:38:15 +00:00
Merge pull request #551 from libexpat/prevent-doprolog-overflow
[CVE-2022-23990] lib: Prevent integer overflow in function doProlog
This commit is contained in:
commit
5c168279c5
2 changed files with 14 additions and 2 deletions
|
@ -10,12 +10,18 @@ Release x.x.x xxx xxxxxxx xx xxxx
|
|||
for when XML_CONTEXT_BYTES is defined to >0 (which is both
|
||||
common and default).
|
||||
Impact is denial of service or more.
|
||||
#551 CVE-2022-23990 -- Fix unsigned integer overflow in function
|
||||
doProlog triggered by large content in element type
|
||||
declarations when there is an element declaration handler
|
||||
present (from a prior call to XML_SetElementDeclHandler).
|
||||
Impact is denial of service or more.
|
||||
|
||||
Bug fixes:
|
||||
#544 #545 xmlwf: Fix a memory leak on output file opening error
|
||||
|
||||
Special thanks to:
|
||||
hwt0415
|
||||
Roland Illig
|
||||
Samanta Navarro
|
||||
and
|
||||
Clang LeakSan and the Clang team
|
||||
|
|
|
@ -5372,7 +5372,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
|
|||
if (dtd->in_eldecl) {
|
||||
ELEMENT_TYPE *el;
|
||||
const XML_Char *name;
|
||||
int nameLen;
|
||||
size_t nameLen;
|
||||
const char *nxt
|
||||
= (quant == XML_CQUANT_NONE ? next : next - enc->minBytesPerChar);
|
||||
int myindex = nextScaffoldPart(parser);
|
||||
|
@ -5388,7 +5388,13 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
|
|||
nameLen = 0;
|
||||
for (; name[nameLen++];)
|
||||
;
|
||||
dtd->contentStringLen += nameLen;
|
||||
|
||||
/* Detect and prevent integer overflow */
|
||||
if (nameLen > UINT_MAX - dtd->contentStringLen) {
|
||||
return XML_ERROR_NO_MEMORY;
|
||||
}
|
||||
|
||||
dtd->contentStringLen += (unsigned)nameLen;
|
||||
if (parser->m_elementDeclHandler)
|
||||
handleDefault = XML_FALSE;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue