mirror of
https://github.com/clearml/dropbear
synced 2025-04-16 21:41:37 +00:00
Fix fuzzing stderr override on os x
This commit is contained in:
parent
bf4058d1df
commit
1b603069db
10
fuzz.h
10
fuzz.h
@ -74,18 +74,24 @@ struct dropbear_fuzz_options {
|
||||
int recv_dumpfd;
|
||||
|
||||
// avoid filling fuzzing logs, this points to /dev/null
|
||||
FILE *stderr;
|
||||
FILE *fake_stderr;
|
||||
};
|
||||
|
||||
extern struct dropbear_fuzz_options fuzz;
|
||||
|
||||
/* guard for when fuzz.h is included by fuzz-common.c */
|
||||
#ifndef FUZZ_NO_REPLACE_STDERR
|
||||
|
||||
/* This is a bodge but seems to work.
|
||||
glibc stdio.h has the comment
|
||||
"C89/C99 say they're macros. Make them happy." */
|
||||
/* OS X has it as a macro */
|
||||
#ifdef stderr
|
||||
#undef stderr
|
||||
#endif
|
||||
#define stderr (fuzz.stderr)
|
||||
#define stderr (fuzz.fake_stderr)
|
||||
|
||||
#endif /* FUZZ_NO_REPLACE_STDERR */
|
||||
|
||||
#endif // DROPBEAR_FUZZ
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "includes.h"
|
||||
|
||||
#include "includes.h"
|
||||
#include "fuzz.h"
|
||||
#include "dbutil.h"
|
||||
#include "runopts.h"
|
||||
#include "crypto_desc.h"
|
||||
@ -11,8 +10,14 @@
|
||||
#include "atomicio.h"
|
||||
#include "fuzz-wrapfd.h"
|
||||
|
||||
#define FUZZ_NO_REPLACE_STDERR
|
||||
#include "fuzz.h"
|
||||
|
||||
/* fuzz.h redefines stderr, we don't want that here */
|
||||
#ifdef origstderr
|
||||
#undef stderr
|
||||
#define stderr origstderr
|
||||
#endif // origstderr
|
||||
|
||||
struct dropbear_fuzz_options fuzz;
|
||||
|
||||
@ -23,7 +28,7 @@ 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;
|
||||
fuzz.fake_stderr = stderr;
|
||||
}
|
||||
|
||||
void fuzz_common_setup(void) {
|
||||
@ -50,8 +55,8 @@ void fuzz_common_setup(void) {
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Dropbear fuzzer: Disabling stderr output\n");
|
||||
fuzz.stderr = fopen("/dev/null", "w");
|
||||
assert(fuzz.stderr);
|
||||
fuzz.fake_stderr = fopen("/dev/null", "w");
|
||||
assert(fuzz.fake_stderr);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user