1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-28 23:14:57 +03:00

fuzz: Cap URL size

Cap URL size to avoid quadratic behavior when generating error messages.
This commit is contained in:
Nick Wellnhofer
2024-01-07 15:19:58 +01:00
parent 83c1ae13d8
commit fd801845c8

View File

@@ -304,16 +304,21 @@ xmlFuzzReadEntities(void) {
while (1) {
const char *url, *entity;
size_t entitySize;
size_t urlSize, entitySize;
xmlFuzzEntityInfo *entityInfo;
url = xmlFuzzReadString(NULL);
url = xmlFuzzReadString(&urlSize);
if (url == NULL) break;
entity = xmlFuzzReadString(&entitySize);
if (entity == NULL) break;
if (xmlHashLookup(fuzzData.entities, (xmlChar *)url) == NULL) {
/*
* Cap URL size to avoid quadratic behavior when generating
* error messages or looking up entities.
*/
if (urlSize < 50 &&
xmlHashLookup(fuzzData.entities, (xmlChar *)url) == NULL) {
entityInfo = xmlMalloc(sizeof(xmlFuzzEntityInfo));
if (entityInfo == NULL)
break;