summaryrefslogtreecommitdiff
path: root/dbutil.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2017-05-25 22:20:10 +0800
committerMatt Johnston <matt@ucc.asn.au>2017-05-25 22:20:10 +0800
commitacd98c9742e9bac48d67a73cdb349c684c1c385b (patch)
treed47682698b2d66a40cd9c1cb19ece90e30fa9c83 /dbutil.c
parentb03953e863a2eef2a0b6588cdc70476db78d65b3 (diff)
downloaddropbear-acd98c9742e9bac48d67a73cdb349c684c1c385b.tar.gz
fuzzing has a constant time
Diffstat (limited to 'dbutil.c')
-rw-r--r--dbutil.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/dbutil.c b/dbutil.c
index d9bb2dd..64e87e8 100644
--- a/dbutil.c
+++ b/dbutil.c
@@ -625,7 +625,14 @@ static clockid_t get_linux_clock_source() {
#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 @@ time_t monotonic_now() {
}
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 @@ time_t monotonic_now() {
}
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 */