You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2018/04/10 21:17:13 UTC
[19/55] [abbrv] qpid-proton git commit: PROTON-1412 add
StandaloneFuzzTargetMain.c from the LLVM project
PROTON-1412 add StandaloneFuzzTargetMain.c from the LLVM project
Version (git commit hash): 98711e2
Url: https://raw.githubusercontent.com/llvm-mirror/llvm/master/lib/Fuzzer/standalone/StandaloneFuzzTargetMain.c
Licence: University of Illinois Open Source license
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/40e3dcbe
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/40e3dcbe
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/40e3dcbe
Branch: refs/heads/go1
Commit: 40e3dcbe65ce390bb3d367ce3c9732ccf10e9639
Parents: 70c8ac8
Author: Ji?? Dan?k <dn...@mail.muni.cz>
Authored: Sat Feb 25 20:41:37 2017 +0100
Committer: Andrew Stitcher <as...@apache.org>
Committed: Wed Mar 21 20:32:51 2018 -0400
----------------------------------------------------------------------
.../src/tests/fuzz/StandaloneFuzzTargetMain.c | 41 ++++++++++++++++++++
1 file changed, 41 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/40e3dcbe/proton-c/src/tests/fuzz/StandaloneFuzzTargetMain.c
----------------------------------------------------------------------
diff --git a/proton-c/src/tests/fuzz/StandaloneFuzzTargetMain.c b/proton-c/src/tests/fuzz/StandaloneFuzzTargetMain.c
new file mode 100644
index 0000000..0d76ea4
--- /dev/null
+++ b/proton-c/src/tests/fuzz/StandaloneFuzzTargetMain.c
@@ -0,0 +1,41 @@
+/*===- StandaloneFuzzTargetMain.c - standalone main() for fuzz targets. ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// This main() function can be linked to a fuzz target (i.e. a library
+// that exports LLVMFuzzerTestOneInput() and possibly LLVMFuzzerInitialize())
+// instead of libFuzzer. This main() function will not perform any fuzzing
+// but will simply feed all input files one by one to the fuzz target.
+//
+// Use this file to provide reproducers for bugs when linking against libFuzzer
+// or other fuzzing engine is undesirable.
+//===----------------------------------------------------------------------===*/
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size);
+__attribute__((weak)) extern int LLVMFuzzerInitialize(int *argc, char ***argv);
+int main(int argc, char **argv) {
+ fprintf(stderr, "StandaloneFuzzTargetMain: running %d inputs\n", argc - 1);
+ if (LLVMFuzzerInitialize)
+ LLVMFuzzerInitialize(&argc, &argv);
+ for (int i = 1; i < argc; i++) {
+ fprintf(stderr, "Running: %s\n", argv[i]);
+ FILE *f = fopen(argv[i], "r");
+ assert(f);
+ fseek(f, 0, SEEK_END);
+ size_t len = ftell(f);
+ fseek(f, 0, SEEK_SET);
+ unsigned char *buf = (unsigned char*)malloc(len);
+ size_t n_read = fread(buf, 1, len, f);
+ assert(n_read == len);
+ LLVMFuzzerTestOneInput(buf, len);
+ free(buf);
+ fprintf(stderr, "Done: %s: (%zd bytes)\n", argv[i], n_read);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org