]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Use timingsafe_memcmp() where available.
authorNick Mathewson <nickm@torproject.org>
Tue, 29 Dec 2015 14:43:01 +0000 (09:43 -0500)
committerNick Mathewson <nickm@torproject.org>
Tue, 29 Dec 2015 14:43:01 +0000 (09:43 -0500)
See ticket 17944; patch from "logan".

changes/17944 [new file with mode: 0644]
configure.ac
src/common/di_ops.c

diff --git a/changes/17944 b/changes/17944
new file mode 100644 (file)
index 0000000..b279506
--- /dev/null
@@ -0,0 +1,3 @@
+  o Minor features (portability):
+    - Use timingsafe_memcmp() where available. Closes ticket 17944;
+      patch from "logan".
index ad86f764de5c4a01a19b3cc8c70d391f050f49cf..a47cee6058eb30c1263ab75eb212839c8e4e610e 100644 (file)
@@ -381,6 +381,7 @@ AC_CHECK_FUNCS(
         backtrace_symbols_fd \
         clock_gettime \
        eventfd \
+       timingsafe_memcmp \
         flock \
         ftime \
         getaddrinfo \
index c9d1350880a72eb2e36281da1f0d41a7ac11bba3..70f2da737711671bc1e0ffe9f25d2e948e9f51c3 100644 (file)
@@ -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 */
 }
 
 /**