# HG changeset patch # User Matt Johnston # Date 1495722010 -28800 # Node ID d8215479a58aa2b4abab1a7654d83721d3f83564 # Parent 4b1a807a31886f8988ee3dbb1bc0728755e7c7b7 fuzzing has a constant time diff -r 4b1a807a3188 -r d8215479a58a dbutil.c --- a/dbutil.c Thu May 25 22:19:46 2017 +0800 +++ b/dbutil.c Thu May 25 22:20:10 2017 +0800 @@ -625,7 +625,14 @@ #endif time_t monotonic_now() { +#ifdef DROPBEAR_FUZZ + if (fuzz.fuzzing) { + /* time stands still when fuzzing */ + return 5; + } +#endif #if defined(__linux__) && defined(SYS_clock_gettime) + { static clockid_t clock_source = -2; if (clock_source == -2) { @@ -642,9 +649,11 @@ } return ts.tv_sec; } + } #endif /* linux clock_gettime */ #if defined(HAVE_MACH_ABSOLUTE_TIME) + { /* OS X, see https://developer.apple.com/library/mac/qa/qa1398/_index.html */ static mach_timebase_info_data_t timebase_info; if (timebase_info.denom == 0) { @@ -652,6 +661,7 @@ } return mach_absolute_time() * timebase_info.numer / timebase_info.denom / 1e9; + } #endif /* osx mach_absolute_time */ /* Fallback for everything else - this will sometimes go backwards */