summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-01-03 09:00:00 -0500
committerNick Mathewson <nickm@torproject.org>2018-01-03 09:00:00 -0500
commit1a070767de0c50aed86f5fc3dc04324e03ef3d32 (patch)
tree395c2f5d15b00472f8ba92e7c4af5f3c8c125757
parent99b4f868332b3ae304e669240657994022d69991 (diff)
parent451c852a0f75fe9ac6935851e763a948c1c5b197 (diff)
downloadtor-1a070767de0c50aed86f5fc3dc04324e03ef3d32.tar.gz
tor-1a070767de0c50aed86f5fc3dc04324e03ef3d32.zip
Merge branch 'maint-0.3.2' into release-0.3.2
-rw-r--r--changes/bug246335
-rw-r--r--src/ext/timeouts/timeout-bitops.c4
2 files changed, 7 insertions, 2 deletions
diff --git a/changes/bug24633 b/changes/bug24633
new file mode 100644
index 0000000000..028c7cc143
--- /dev/null
+++ b/changes/bug24633
@@ -0,0 +1,5 @@
+ o Minor bugfixes (portability, msvc):
+ - Fix a bug in the bit-counting parts of our timing-wheel code on
+ MSVC. (Note that MSVC is still not a supported build platform,
+ due to cyptographic timing channel risks.) Fixes bug 24633;
+ bugfix on 0.2.9.1-alpha.
diff --git a/src/ext/timeouts/timeout-bitops.c b/src/ext/timeouts/timeout-bitops.c
index e99af8f9c4..68db817933 100644
--- a/src/ext/timeouts/timeout-bitops.c
+++ b/src/ext/timeouts/timeout-bitops.c
@@ -40,7 +40,7 @@ static __inline int clz32(unsigned long val)
{
DWORD zeros = 0;
_BitScanReverse(&zeros, val);
- return zeros;
+ return 31 - zeros;
}
#ifdef _WIN64
/* According to the documentation, these only exist on Win64. */
@@ -54,7 +54,7 @@ static __inline int clz64(uint64_t val)
{
DWORD zeros = 0;
_BitScanReverse64(&zeros, val);
- return zeros;
+ return 63 - zeros;
}
#else
static __inline int ctz64(uint64_t val)