summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/utf8proc/test/fuzz_main.c
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2023-12-06 07:05:45 +1100
committer Vas Crabb <vas@vastheman.com>2023-12-06 07:05:45 +1100
commit466c450cb37c9077e799fe9f59137096fd35e8f6 (patch)
tree2d62bb8ecb8012a9f0d4eb75da3f4d65192c5b53 /3rdparty/utf8proc/test/fuzz_main.c
parent12590d6ad8873bb8d8c217b67311290653d948d2 (diff)
3rdparty/utf8proc: Updated to 2.9.0.
Diffstat (limited to '3rdparty/utf8proc/test/fuzz_main.c')
-rw-r--r--3rdparty/utf8proc/test/fuzz_main.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/3rdparty/utf8proc/test/fuzz_main.c b/3rdparty/utf8proc/test/fuzz_main.c
new file mode 100644
index 00000000000..39bf14738c2
--- /dev/null
+++ b/3rdparty/utf8proc/test/fuzz_main.c
@@ -0,0 +1,54 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+/* Fuzz target entry point, works without libFuzzer */
+
+int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);
+
+int main(int argc, char **argv)
+{
+ FILE *f;
+ char *buf = NULL;
+ long siz_buf;
+
+ if(argc < 2)
+ {
+ fprintf(stderr, "no input file\n");
+ goto err;
+ }
+
+ f = fopen(argv[1], "rb");
+ if(f == NULL)
+ {
+ fprintf(stderr, "error opening input file %s\n", argv[1]);
+ goto err;
+ }
+
+ fseek(f, 0, SEEK_END);
+
+ siz_buf = ftell(f);
+ rewind(f);
+
+ if(siz_buf < 1) goto err;
+
+ buf = (char*)malloc(siz_buf);
+ if(buf == NULL)
+ {
+ fprintf(stderr, "malloc() failed\n");
+ goto err;
+ }
+
+ if(fread(buf, siz_buf, 1, f) != 1)
+ {
+ fprintf(stderr, "fread() failed\n");
+ goto err;
+ }
+
+ (void)LLVMFuzzerTestOneInput((uint8_t*)buf, siz_buf);
+
+err:
+ free(buf);
+
+ return 0;
+}