1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-27 18:50:07 +03:00

parser: Fix OOB read when formatting error message

Don't try to print characters beyond the end of the buffer.

Found by OSS-Fuzz.
This commit is contained in:
Nick Wellnhofer 2023-02-18 17:29:07 +01:00
parent 1743c4c3fc
commit 5d55315e32

@ -12106,7 +12106,11 @@ done:
#endif
return(ret);
encoding_error:
{
if (ctxt->input->end - ctxt->input->cur < 4) {
__xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR,
"Input is not proper UTF-8, indicate encoding !\n",
NULL, NULL);
} else {
char buffer[150];
snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",