summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2018-08-22 16:03:52 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2018-08-22 16:03:52 +0200
commit77606ed0b26aa364dd53b1b9689ff3fd8f0489f3 (patch)
treeeb8e0320a237ac680a21a2b9f2f206c8ca625456
parent0c1cbd4701b8a2e4d6f792f393bac3e3d04579b6 (diff)
xml: improve handling of invalid long data entities
this also fixes an issue with truncating and missing data on invalid input.
-rw-r--r--xml.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/xml.c b/xml.c
index 6b58bd4..c4573b4 100644
--- a/xml.c
+++ b/xml.c
@@ -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);