Files
RedBear-OS/recipes/libs/libxml2/source/fuzz/uri.c
T
vasilito ff4ff35918 feat: track all source trees in git — full fork offline-first model
Red Bear OS is a full fork. All sources must be available from git clone
with zero network access. Removed gitignore rules that excluded fetched
source trees under recipes/*/source/, local/recipes/kde/*/source/,
local/recipes/qt/*/source/, and vendor source trees.

Build artifacts (target/, build/, source.tar, *.o, *.so) remain excluded.

127291 files added — kernel, relibc, base, bootloader, pkgar, all KDE/Qt
frameworks, mesa, wayland, DRM drivers, and every other recipe source.
2026-05-14 10:55:53 +01:00

63 lines
1.4 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
LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
char ***argv ATTRIBUTE_UNUSED) {
xmlFuzzMemSetup();
xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
return 0;
}
int
LLVMFuzzerTestOneInput(const char *data, size_t size) {
xmlURIPtr uri;
size_t maxAlloc;
const char *str1, *str2;
char *copy;
if (size > 10000)
return(0);
xmlFuzzDataInit(data, size);
maxAlloc = xmlFuzzReadInt(4) % (size * 8 + 1);
str1 = xmlFuzzReadString(NULL);
str2 = xmlFuzzReadString(NULL);
xmlFuzzMemSetLimit(maxAlloc);
uri = xmlParseURI(str1);
xmlFree(xmlSaveUri(uri));
xmlFreeURI(uri);
uri = xmlParseURIRaw(str1, 1);
xmlFree(xmlSaveUri(uri));
xmlFreeURI(uri);
xmlFree(xmlURIUnescapeString(str1, -1, NULL));
xmlFree(xmlURIEscape(BAD_CAST str1));
xmlFree(xmlCanonicPath(BAD_CAST str1));
xmlFree(xmlPathToURI(BAD_CAST str1));
xmlFree(xmlBuildURI(BAD_CAST str2, BAD_CAST str1));
xmlFree(xmlBuildRelativeURI(BAD_CAST str2, BAD_CAST str1));
xmlFree(xmlURIEscapeStr(BAD_CAST str1, BAD_CAST str2));
copy = (char *) xmlCharStrdup(str1);
xmlNormalizeURIPath(copy);
xmlFree(copy);
xmlFuzzMemSetLimit(0);
xmlFuzzDataCleanup();
return 0;
}