mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2024-12-24 21:33:51 +03:00
parser: Check for truncated multi-byte sequences
When decoding input data, check whether the "raw" buffer is empty after parsing the document. Otherwise, the input ends with a truncated multi-byte sequence which shouldn't be silently ignored.
This commit is contained in:
parent
95e81a360c
commit
855818bd2b
14
parser.c
14
parser.c
@ -10455,7 +10455,12 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
|
||||
|
||||
if (RAW != 0) {
|
||||
xmlFatalErr(ctxt, XML_ERR_DOCUMENT_END, NULL);
|
||||
}
|
||||
} else if ((ctxt->input->buf != NULL) &&
|
||||
(ctxt->input->buf->encoder != NULL) &&
|
||||
(!xmlBufIsEmpty(ctxt->input->buf->raw))) {
|
||||
xmlFatalErrMsg(ctxt, XML_ERR_INVALID_CHAR,
|
||||
"Truncated multi-byte sequence at EOF\n");
|
||||
}
|
||||
ctxt->instate = XML_PARSER_EOF;
|
||||
}
|
||||
|
||||
@ -11686,7 +11691,12 @@ xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size,
|
||||
if ((ctxt->instate == XML_PARSER_EPILOG) &&
|
||||
(ctxt->input->cur < ctxt->input->end)) {
|
||||
xmlFatalErr(ctxt, XML_ERR_DOCUMENT_END, NULL);
|
||||
}
|
||||
} else if ((ctxt->input->buf != NULL) &&
|
||||
(ctxt->input->buf->encoder != NULL) &&
|
||||
(!xmlBufIsEmpty(ctxt->input->buf->raw))) {
|
||||
xmlFatalErrMsg(ctxt, XML_ERR_INVALID_CHAR,
|
||||
"Truncated multi-byte sequence at EOF\n");
|
||||
}
|
||||
if (ctxt->instate != XML_PARSER_EOF) {
|
||||
if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
|
||||
ctxt->sax->endDocument(ctxt->userData);
|
||||
|
3
result/errors/truncated-utf16.xml.ent
Normal file
3
result/errors/truncated-utf16.xml.ent
Normal file
@ -0,0 +1,3 @@
|
||||
./test/errors/truncated-utf16.xml:1: parser error : Truncated multi-byte sequence at EOF
|
||||
<d/>
|
||||
^
|
3
result/errors/truncated-utf16.xml.err
Normal file
3
result/errors/truncated-utf16.xml.err
Normal file
@ -0,0 +1,3 @@
|
||||
./test/errors/truncated-utf16.xml:1: parser error : Truncated multi-byte sequence at EOF
|
||||
<d/>
|
||||
^
|
4
result/errors/truncated-utf16.xml.str
Normal file
4
result/errors/truncated-utf16.xml.str
Normal file
@ -0,0 +1,4 @@
|
||||
./test/errors/truncated-utf16.xml:1: parser error : Truncated multi-byte sequence at EOF
|
||||
<d/>
|
||||
^
|
||||
./test/errors/truncated-utf16.xml : failed to parse
|
BIN
test/errors/truncated-utf16.xml
Normal file
BIN
test/errors/truncated-utf16.xml
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user