Mercurial > dropbear
comparison fuzz/fuzz-common.c @ 1768:096a66e45212
Fix fuzzing stderr override on os x
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 26 Oct 2020 23:44:43 +0800 |
parents | 3e1e1f82eba6 |
children | 66b29b054896 |
comparison
equal
deleted
inserted
replaced
1767:3e1e1f82eba6 | 1768:096a66e45212 |
---|---|
1 #include "includes.h" | 1 #include "includes.h" |
2 | 2 |
3 #include "includes.h" | 3 #include "includes.h" |
4 #include "fuzz.h" | |
5 #include "dbutil.h" | 4 #include "dbutil.h" |
6 #include "runopts.h" | 5 #include "runopts.h" |
7 #include "crypto_desc.h" | 6 #include "crypto_desc.h" |
8 #include "session.h" | 7 #include "session.h" |
9 #include "dbrandom.h" | 8 #include "dbrandom.h" |
10 #include "bignum.h" | 9 #include "bignum.h" |
11 #include "atomicio.h" | 10 #include "atomicio.h" |
12 #include "fuzz-wrapfd.h" | 11 #include "fuzz-wrapfd.h" |
13 | 12 |
13 #define FUZZ_NO_REPLACE_STDERR | |
14 #include "fuzz.h" | |
15 | |
14 /* fuzz.h redefines stderr, we don't want that here */ | 16 /* fuzz.h redefines stderr, we don't want that here */ |
17 #ifdef origstderr | |
15 #undef stderr | 18 #undef stderr |
19 #define stderr origstderr | |
20 #endif // origstderr | |
16 | 21 |
17 struct dropbear_fuzz_options fuzz; | 22 struct dropbear_fuzz_options fuzz; |
18 | 23 |
19 static void fuzz_dropbear_log(int UNUSED(priority), const char* format, va_list param); | 24 static void fuzz_dropbear_log(int UNUSED(priority), const char* format, va_list param); |
20 static void load_fixed_hostkeys(void); | 25 static void load_fixed_hostkeys(void); |
21 static void load_fixed_client_key(void); | 26 static void load_fixed_client_key(void); |
22 | 27 |
23 // This runs automatically before main, due to contructor attribute in fuzz.h | 28 // This runs automatically before main, due to contructor attribute in fuzz.h |
24 void fuzz_early_setup(void) { | 29 void fuzz_early_setup(void) { |
25 /* Set stderr to point to normal stderr by default */ | 30 /* Set stderr to point to normal stderr by default */ |
26 fuzz.stderr = stderr; | 31 fuzz.fake_stderr = stderr; |
27 } | 32 } |
28 | 33 |
29 void fuzz_common_setup(void) { | 34 void fuzz_common_setup(void) { |
30 disallow_core(); | 35 disallow_core(); |
31 fuzz.fuzzing = 1; | 36 fuzz.fuzzing = 1; |
48 fprintf(stderr, "Dropbear fuzzer: DROPBEAR_KEEP_STDERR, not disabling stderr output\n"); | 53 fprintf(stderr, "Dropbear fuzzer: DROPBEAR_KEEP_STDERR, not disabling stderr output\n"); |
49 } | 54 } |
50 else | 55 else |
51 { | 56 { |
52 fprintf(stderr, "Dropbear fuzzer: Disabling stderr output\n"); | 57 fprintf(stderr, "Dropbear fuzzer: Disabling stderr output\n"); |
53 fuzz.stderr = fopen("/dev/null", "w"); | 58 fuzz.fake_stderr = fopen("/dev/null", "w"); |
54 assert(fuzz.stderr); | 59 assert(fuzz.fake_stderr); |
55 } | 60 } |
56 } | 61 } |
57 | 62 |
58 int fuzz_set_input(const uint8_t *Data, size_t Size) { | 63 int fuzz_set_input(const uint8_t *Data, size_t Size) { |
59 | 64 |