size_t FuzzerRandomLibc::Rand() { return rand(); }
-UserSuppliedFuzzer::UserSuppliedFuzzer()
- : OwnRand(true), Rand(new FuzzerRandomLibc(0)), MD(*Rand) {}
-
UserSuppliedFuzzer::UserSuppliedFuzzer(FuzzerRandomBase *Rand)
: Rand(Rand), MD(*Rand) {}
namespace fuzzer {
-typedef void (*DeprecatedUserCallback)(const uint8_t *Data, size_t Size);
/// Returns an int 0. Values other than zero are reserved for future.
typedef int (*UserCallback)(const uint8_t *Data, size_t Size);
/** Simple C-like interface with a single user-supplied callback.
#\endcode
*/
int FuzzerDriver(int argc, char **argv, UserCallback Callback);
-int FuzzerDriver(int argc, char **argv, DeprecatedUserCallback Callback);
class FuzzerRandomBase {
public:
*/
class UserSuppliedFuzzer {
public:
- UserSuppliedFuzzer(); // Deprecated, don't use.
UserSuppliedFuzzer(FuzzerRandomBase *Rand);
/// Executes the target function on 'Size' bytes of 'Data'.
virtual int TargetFunction(const uint8_t *Data, size_t Size) = 0;
SimpleUserSuppliedFuzzer(FuzzerRandomBase *Rand, UserCallback Callback)
: UserSuppliedFuzzer(Rand), Callback(Callback) {}
- SimpleUserSuppliedFuzzer(FuzzerRandomBase *Rand, DeprecatedUserCallback Callback)
- : UserSuppliedFuzzer(Rand), DeprecatedCallback(Callback) {}
-
virtual int TargetFunction(const uint8_t *Data, size_t Size) override {
- if (Callback) return Callback(Data, Size);
- DeprecatedCallback(Data, Size);
- return 0;
+ return Callback(Data, Size);
}
private:
- DeprecatedUserCallback DeprecatedCallback = nullptr;
UserCallback Callback = nullptr;
};
extern "C" {
__attribute__((weak)) void __sanitizer_print_stack_trace();
+__attribute__((weak)) size_t __sanitizer_get_total_unique_caller_callee_pairs();
}
namespace fuzzer {
size_t Fuzzer::RecordCallerCalleeCoverage() {
if (!Options.UseIndirCalls)
return 0;
+ if (!__sanitizer_get_total_unique_caller_callee_pairs)
+ return 0;
return LastRecordedCallerCalleeCoverage =
__sanitizer_get_total_unique_caller_callee_pairs();
}