aboutsummaryrefslogtreecommitdiff
path: root/src/common/di_ops.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/di_ops.c')
-rw-r--r--src/common/di_ops.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/common/di_ops.c b/src/common/di_ops.c
index 14a1443400..5dfe828066 100644
--- a/src/common/di_ops.c
+++ b/src/common/di_ops.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2013, The Tor Project, Inc. */
+/* Copyright (c) 2011-2016, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -25,6 +25,9 @@
int
tor_memcmp(const void *a, const void *b, size_t len)
{
+#ifdef HAVE_TIMINGSAFE_MEMCMP
+ return timingsafe_memcmp(a, b, len);
+#else
const uint8_t *x = a;
const uint8_t *y = b;
size_t i = len;
@@ -83,6 +86,7 @@ tor_memcmp(const void *a, const void *b, size_t len)
}
return retval;
+#endif /* timingsafe_memcmp */
}
/**
@@ -130,6 +134,7 @@ tor_memeq(const void *a, const void *b, size_t sz)
* 1 & ((any_difference - 1) >> 8) == 0
*/
+ /*coverity[overflow]*/
return 1 & ((any_difference - 1) >> 8);
}
@@ -217,6 +222,7 @@ safe_mem_is_zero(const void *mem, size_t sz)
total |= *ptr++;
}
+ /*coverity[overflow]*/
return 1 & ((total - 1) >> 8);
}