xml: improve handling of invalid long data entities

this also fixes an issue with truncating and missing data on invalid input.
This commit is contained in:
Hiltjo Posthuma 2018-08-22 16:03:52 +02:00
parent 0c1cbd4701
commit 77606ed0b2
1 changed files with 9 additions and 2 deletions

11
xml.c
View File

@ -416,9 +416,16 @@ xml_parse(XMLParser *x)
break;
if (datalen < sizeof(x->data) - 1)
x->data[datalen++] = c;
if (isspace(c))
else {
/* entity too long for buffer, handle as normal data */
x->data[datalen] = '\0';
if (x->xmldata)
x->xmldata(x, x->data, datalen);
x->data[0] = c;
datalen = 1;
break;
else if (c == ';') {
}
if (c == ';') {
x->data[datalen] = '\0';
if (x->xmldataentity)
x->xmldataentity(x, x->data, datalen);