summaryrefslogtreecommitdiff
path: root/fuzz/fuzz-common.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2020-10-24 22:40:08 +0800
committerMatt Johnston <matt@ucc.asn.au>2020-10-24 22:40:08 +0800
commit37ab00c357b4f5eff95d3f796c675e32b1d98eb5 (patch)
tree94a5c80fb98ed32d8532363e0e66d39b239ca642 /fuzz/fuzz-common.c
parent6e9444ec094f8d65f339b89cadaebdb609ea4f59 (diff)
downloaddropbear-37ab00c357b4f5eff95d3f796c675e32b1d98eb5.tar.gz
Disable stderr output for fuzzer by default
Diffstat (limited to 'fuzz/fuzz-common.c')
-rw-r--r--fuzz/fuzz-common.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/fuzz/fuzz-common.c b/fuzz/fuzz-common.c
index a158691..065b7d9 100644
--- a/fuzz/fuzz-common.c
+++ b/fuzz/fuzz-common.c
@@ -11,12 +11,21 @@
#include "atomicio.h"
#include "fuzz-wrapfd.h"
+/* fuzz.h redefines stderr, we don't want that here */
+#undef stderr
+
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);
static void load_fixed_client_key(void);
+// This runs automatically before main, due to contructor attribute in fuzz.h
+void fuzz_early_setup(void) {
+ /* Set stderr to point to normal stderr by default */
+ fuzz.stderr = stderr;
+}
+
void fuzz_common_setup(void) {
disallow_core();
fuzz.fuzzing = 1;
@@ -28,6 +37,18 @@ void fuzz_common_setup(void) {
fuzz_seed("start", 5);
/* let any messages get flushed */
setlinebuf(stdout);
+#if DEBUG_TRACE
+ if (debug_trace)
+ {
+ fprintf(stderr, "Dropbear fuzzer: -v specified, not disabling stderr output\n");
+ }
+ else
+#endif
+ {
+ fprintf(stderr, "Dropbear fuzzer: Disabling stderr output\n");
+ fuzz.stderr = fopen("/dev/null", "w");
+ assert(fuzz.stderr);
+ }
}
int fuzz_set_input(const uint8_t *Data, size_t Size) {