]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Avoid integer error in TEST_BITOPS tests
authorNick Mathewson <nickm@torproject.org>
Tue, 19 Sep 2017 17:58:35 +0000 (13:58 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 19 Sep 2017 17:58:35 +0000 (13:58 -0400)
If "1" is not 64 bits wide already, then "1 << i" will not actually
work.

This bug only affects the TEST_BITOPS code, and shouldn't matter for
the actual use of the timeout code (except if/when it causes this
test to fail).

Reported by dcb314@hotmail.com.  Fix for bug 23583.  Not adding a
changes file, since this code is never compiled into Tor.

src/ext/timeouts/timeout-bitops.c

index a018f33b9585002cae7fa17b6a0577d5e1f6cc1f..e99af8f9c41e84abbf5736e6c8b95200bc378376 100644 (file)
@@ -231,7 +231,8 @@ main(int c, char **v)
        int result = 0;
 
        for (i = 0; i <= 63; ++i) {
-               uint64_t x = 1 << i;
+               uint64_t x = 1;
+               x <<= i;
                if (!check(x))
                        result = 1;
                --x;