changeset 1373:9891bc31a1b3 fuzz

fuzzers disable logging by default
author Matt Johnston <matt@ucc.asn.au>
date Thu, 25 May 2017 00:12:07 +0800
parents de1d895b1cae
children 4b1a807a3188
files fuzz-common.c fuzz-harness.c
diffstat 2 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/fuzz-common.c	Thu May 25 00:10:18 2017 +0800
+++ b/fuzz-common.c	Thu May 25 00:12:07 2017 +0800
@@ -11,12 +11,14 @@
 
 struct dropbear_fuzz_options fuzz;
 
+static void fuzz_dropbear_log(int UNUSED(priority), const char* format, va_list param);
 static void load_fixed_hostkeys(void);
 
 void common_setup_fuzzer(void) {
     fuzz.fuzzing = 1;
     fuzz.wrapfds = 1;
     fuzz.input = m_malloc(sizeof(buffer));
+    _dropbear_log = fuzz_dropbear_log;
     crypto_init();
 }
 
@@ -52,6 +54,17 @@
     return DROPBEAR_SUCCESS;
 }
 
+static void fuzz_dropbear_log(int UNUSED(priority), const char* format, va_list param) {
+
+    char printbuf[1024];
+
+#if DEBUG_TRACE
+    if (debug_trace) {
+        vsnprintf(printbuf, sizeof(printbuf), format, param);
+        fprintf(stderr, "%s\n", printbuf);
+    }
+#endif
+}
 
 void svr_setup_fuzzer(void) {
     struct passwd *pw;
@@ -59,7 +72,6 @@
     common_setup_fuzzer();
     
     _dropbear_exit = svr_dropbear_exit;
-    _dropbear_log = svr_dropbear_log;
 
     char *argv[] = { 
         "-E", 
--- a/fuzz-harness.c	Thu May 25 00:10:18 2017 +0800
+++ b/fuzz-harness.c	Thu May 25 00:12:07 2017 +0800
@@ -12,6 +12,7 @@
 #if DEBUG_TRACE
         if (strcmp(argv[i], "-v") == 0) {
             debug_trace = 1;
+            TRACE(("debug printing on"))
         }
 #endif
     }