Skip to content
Snippets Groups Projects
Commit 87c4586d authored by Matt Johnston's avatar Matt Johnston
Browse files

fuzzing has a constant time

--HG--
branch : fuzz
parent b1725492
Branches
No related merge requests found
...@@ -625,7 +625,14 @@ static clockid_t get_linux_clock_source() { ...@@ -625,7 +625,14 @@ static clockid_t get_linux_clock_source() {
#endif #endif
time_t monotonic_now() { 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) #if defined(__linux__) && defined(SYS_clock_gettime)
{
static clockid_t clock_source = -2; static clockid_t clock_source = -2;
if (clock_source == -2) { if (clock_source == -2) {
...@@ -642,9 +649,11 @@ time_t monotonic_now() { ...@@ -642,9 +649,11 @@ time_t monotonic_now() {
} }
return ts.tv_sec; return ts.tv_sec;
} }
}
#endif /* linux clock_gettime */ #endif /* linux clock_gettime */
#if defined(HAVE_MACH_ABSOLUTE_TIME) #if defined(HAVE_MACH_ABSOLUTE_TIME)
{
/* OS X, see https://developer.apple.com/library/mac/qa/qa1398/_index.html */ /* OS X, see https://developer.apple.com/library/mac/qa/qa1398/_index.html */
static mach_timebase_info_data_t timebase_info; static mach_timebase_info_data_t timebase_info;
if (timebase_info.denom == 0) { if (timebase_info.denom == 0) {
...@@ -652,6 +661,7 @@ time_t monotonic_now() { ...@@ -652,6 +661,7 @@ time_t monotonic_now() {
} }
return mach_absolute_time() * timebase_info.numer / timebase_info.denom return mach_absolute_time() * timebase_info.numer / timebase_info.denom
/ 1e9; / 1e9;
}
#endif /* osx mach_absolute_time */ #endif /* osx mach_absolute_time */
/* Fallback for everything else - this will sometimes go backwards */ /* Fallback for everything else - this will sometimes go backwards */
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment