From bc2cd0ff2bfc70916efe6b6a7fe0a4aae481df3b Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 29 Dec 2015 09:43:01 -0500 Subject: [PATCH] Use timingsafe_memcmp() where available. See ticket 17944; patch from "logan". --- changes/17944 | 3 +++ configure.ac | 1 + src/common/di_ops.c | 4 ++++ 3 files changed, 8 insertions(+) create mode 100644 changes/17944 diff --git a/changes/17944 b/changes/17944 new file mode 100644 index 0000000000..b2795064e6 --- /dev/null +++ b/changes/17944 @@ -0,0 +1,3 @@ + o Minor features (portability): + - Use timingsafe_memcmp() where available. Closes ticket 17944; + patch from "logan". diff --git a/configure.ac b/configure.ac index ad86f764de..a47cee6058 100644 --- a/configure.ac +++ b/configure.ac @@ -381,6 +381,7 @@ AC_CHECK_FUNCS( backtrace_symbols_fd \ clock_gettime \ eventfd \ + timingsafe_memcmp \ flock \ ftime \ getaddrinfo \ diff --git a/src/common/di_ops.c b/src/common/di_ops.c index c9d1350880..70f2da7377 100644 --- a/src/common/di_ops.c +++ b/src/common/di_ops.c @@ -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 */ } /**