1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

fixed bug #381877, avoid reading over the end of stream when generating an

* HTMLparser.c: fixed bug #381877, avoid reading over the end
  of stream when generating an UTF-8 encoding error.
Daniel

svn path=/trunk/; revision=3627
This commit is contained in:
Daniel Veillard
2007-06-12 08:38:57 +00:00
parent 2e6208651d
commit 861101d1fa
2 changed files with 12 additions and 3 deletions

View File

@ -401,9 +401,13 @@ encoding_error:
{
char buffer[150];
snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
ctxt->input->cur[0], ctxt->input->cur[1],
ctxt->input->cur[2], ctxt->input->cur[3]);
if (ctxt->input->end - ctxt->input->cur >= 4) {
snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
ctxt->input->cur[0], ctxt->input->cur[1],
ctxt->input->cur[2], ctxt->input->cur[3]);
} else {
snprintf(buffer, 149, "Bytes: 0x%02X\n", ctxt->input->cur[0]);
}
htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
"Input is not proper UTF-8, indicate encoding !\n",
BAD_CAST buffer, NULL);