mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2024-12-24 21:33:51 +03:00
00ed736eec
- XML fuzzer Currently tests the pull parser, push parser and reader, as well as serialization. Supports splitting fuzz data into multiple documents for things like external DTDs or entities. The seed corpus is built from parts of the test suite. - Regexp fuzzer Seed corpus was statically generated from test suite. - URI fuzzer Tests parsing and most other functions from uri.c.
46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
/*
|
|
* uri.c: a libFuzzer target to test the URI module.
|
|
*
|
|
* See Copyright for the status of this software.
|
|
*/
|
|
|
|
#include <libxml/uri.h>
|
|
#include "fuzz.h"
|
|
|
|
int
|
|
LLVMFuzzerTestOneInput(const char *data, size_t size) {
|
|
xmlURIPtr uri;
|
|
char *str[2] = { NULL, NULL };
|
|
size_t numStrings;
|
|
|
|
numStrings = xmlFuzzExtractStrings(data, size, str, 2);
|
|
|
|
uri = xmlParseURI(str[0]);
|
|
xmlFree(xmlSaveUri(uri));
|
|
xmlFreeURI(uri);
|
|
|
|
uri = xmlParseURIRaw(str[0], 1);
|
|
xmlFree(xmlSaveUri(uri));
|
|
xmlFreeURI(uri);
|
|
|
|
xmlFree(xmlURIUnescapeString(str[0], -1, NULL));
|
|
xmlFree(xmlURIEscape(BAD_CAST str[0]));
|
|
xmlFree(xmlCanonicPath(BAD_CAST str[0]));
|
|
xmlFree(xmlPathToURI(BAD_CAST str[0]));
|
|
|
|
if (numStrings >= 2) {
|
|
xmlFree(xmlBuildURI(BAD_CAST str[1], BAD_CAST str[0]));
|
|
xmlFree(xmlBuildRelativeURI(BAD_CAST str[1], BAD_CAST str[0]));
|
|
xmlFree(xmlURIEscapeStr(BAD_CAST str[0], BAD_CAST str[1]));
|
|
}
|
|
|
|
/* Modifies string, so must come last. */
|
|
xmlNormalizeURIPath(str[0]);
|
|
|
|
xmlFree(str[0]);
|
|
xmlFree(str[1]);
|
|
|
|
return 0;
|
|
}
|
|
|