summaryrefslogtreecommitdiff
path: root/tests/fstree_fuzz.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-25 13:46:21 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-25 13:47:25 +0200
commite5fa4cdfb0469ed615d0f778b95b0755bfd7c9ca (patch)
tree4609e87431a8954273a989f11474d503053854b9 /tests/fstree_fuzz.c
parent14f02a946b875459db8b4290d316e7a99c6d9f75 (diff)
Add minimal test program for fuzzing the fstree_from_file parser
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tests/fstree_fuzz.c')
-rw-r--r--tests/fstree_fuzz.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/fstree_fuzz.c b/tests/fstree_fuzz.c
new file mode 100644
index 0000000..a9df1ab
--- /dev/null
+++ b/tests/fstree_fuzz.c
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+/*
+ * fstree_fuzz.c
+ *
+ * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
+ */
+#include "config.h"
+
+#include "fstree.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+ int ret = EXIT_FAILURE;
+ fstree_t fs;
+ FILE *fp;
+
+ if (argc != 2) {
+ fputs("Usage: fstree_fuzz <input_file>\n", stderr);
+ return EXIT_FAILURE;
+ }
+
+ fp = fopen(argv[1], "r");
+ if (fp == NULL) {
+ perror(argv[1]);
+ return EXIT_FAILURE;
+ }
+
+ if (fstree_init(&fs, 512, NULL))
+ goto out_fp;
+
+ if (fstree_from_file(&fs, argv[1], fp))
+ goto out_fs;
+
+ ret = EXIT_SUCCESS;
+out_fs:
+ fstree_cleanup(&fs);
+out_fp:
+ fclose(fp);
+ return ret;
+}