diff fuzzer-preauth.c @ 1348:5c2899e35b63 fuzz

fuzz harness
author Matt Johnston <matt@ucc.asn.au>
date Sat, 13 May 2017 22:50:54 +0800
parents
children 3677a510f545
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fuzzer-preauth.c	Sat May 13 22:50:54 2017 +0800
@@ -0,0 +1,31 @@
+#include "fuzz.h"
+#include "dbrandom.h"
+#include "session.h"
+
+static int setup_fuzzer(void) {
+	svr_setup_fuzzer();
+	return 0;
+}
+
+int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+	static int once = 0;
+	if (!once) {
+		setup_fuzzer();
+		once = 1;
+	}
+
+	fuzz.input.data = (unsigned char*)Data;
+	fuzz.input.size = Size;
+	fuzz.input.len = Size;
+	fuzz.input.pos = 0;
+
+	seedrandom();
+
+	if (setjmp(fuzz.jmp) == 0) {
+		svr_session(-1, -1);
+	} else {
+		// dropbear_exit jumped here
+	}
+
+	return 0;
+}