mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-24 13:33:01 +03:00
parser: Check for integer overflow when updating checkIndex
Unfortunately, checkIndex is a long, not a size_t. Check for integer overflow before updating the value.
This commit is contained in:
@@ -5398,7 +5398,7 @@ static int
|
||||
htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
|
||||
xmlChar next, xmlChar third, int ignoreattrval)
|
||||
{
|
||||
int base, len;
|
||||
size_t base, len;
|
||||
htmlParserInputPtr in;
|
||||
const xmlChar *buf;
|
||||
int quote;
|
||||
@@ -5419,6 +5419,11 @@ htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
|
||||
else if (next)
|
||||
len--;
|
||||
for (; base < len; base++) {
|
||||
if (base >= INT_MAX / 2) {
|
||||
ctxt->checkIndex = 0;
|
||||
ctxt->endCheckState = 0;
|
||||
return (base - 2);
|
||||
}
|
||||
if (ignoreattrval) {
|
||||
if (quote) {
|
||||
if (buf[base] == quote)
|
||||
|
||||
Reference in New Issue
Block a user