mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-24 13:33:01 +03:00
Possible overflow in HTMLParser.c
For https://bugzilla.gnome.org/show_bug.cgi?id=720615 make sure that the encoding string passed is of reasonable size
This commit is contained in:
16
HTMLparser.c
16
HTMLparser.c
@@ -6288,12 +6288,16 @@ htmlCreateFileParserCtxt(const char *filename, const char *encoding)
|
||||
|
||||
/* set encoding */
|
||||
if (encoding) {
|
||||
content = xmlMallocAtomic (xmlStrlen(content_line) + strlen(encoding) + 1);
|
||||
if (content) {
|
||||
strcpy ((char *)content, (char *)content_line);
|
||||
strcat ((char *)content, (char *)encoding);
|
||||
htmlCheckEncoding (ctxt, content);
|
||||
xmlFree (content);
|
||||
size_t l = strlen(encoding);
|
||||
|
||||
if (l < 1000) {
|
||||
content = xmlMallocAtomic (xmlStrlen(content_line) + l + 1);
|
||||
if (content) {
|
||||
strcpy ((char *)content, (char *)content_line);
|
||||
strcat ((char *)content, (char *)encoding);
|
||||
htmlCheckEncoding (ctxt, content);
|
||||
xmlFree (content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user