diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2018-08-22 16:03:52 +0200 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2018-08-22 16:03:52 +0200 |
commit | 77606ed0b26aa364dd53b1b9689ff3fd8f0489f3 (patch) | |
tree | eb8e0320a237ac680a21a2b9f2f206c8ca625456 | |
parent | 0c1cbd4701b8a2e4d6f792f393bac3e3d04579b6 (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.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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); |