summaryrefslogtreecommitdiff
path: root/fuzz-pack-headers.c
diff options
context:
space:
mode:
authorJosh Steadmon <steadmon@google.com>2018-10-13 00:58:40 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-10-15 05:28:59 (GMT)
commit5e47215080018b7eea2054ec70f5d686715d66ee (patch)
tree70f2a6f4c79a0a36855050df84dbcdbe554a3a7c /fuzz-pack-headers.c
parent2efbb7f5218d5ca9d50cbcb86a365a08b2981d77 (diff)
downloadgit-5e47215080018b7eea2054ec70f5d686715d66ee.zip
git-5e47215080018b7eea2054ec70f5d686715d66ee.tar.gz
git-5e47215080018b7eea2054ec70f5d686715d66ee.tar.bz2
fuzz: add basic fuzz testing target.
fuzz-pack-headers.c provides a fuzzing entry point compatible with libFuzzer (and possibly other fuzzing engines). Signed-off-by: Josh Steadmon <steadmon@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fuzz-pack-headers.c')
-rw-r--r--fuzz-pack-headers.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/fuzz-pack-headers.c b/fuzz-pack-headers.c
new file mode 100644
index 0000000..99da1d0
--- /dev/null
+++ b/fuzz-pack-headers.c
@@ -0,0 +1,14 @@
+#include "packfile.h"
+
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
+
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
+{
+ enum object_type type;
+ unsigned long len;
+
+ unpack_object_header_buffer((const unsigned char *)data,
+ (unsigned long)size, &type, &len);
+
+ return 0;
+}