diff options
author | ulfvonbelow <strilen@tilde.club> | 2023-01-29 05:26:48 -0600 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2023-02-06 14:15:47 +0900 |
commit | 7341cdfb5bef6abaf4e12c91d016a940e201e8b7 (patch) | |
tree | 39355bb4ce5e14a13210f90cf23de611f9ddccaa | |
parent | 74bebb5c9f2aa2efc6a74fd4b5d8c2af76742470 (diff) | |
download | gnunet-7341cdfb5bef6abaf4e12c91d016a940e201e8b7.tar.gz gnunet-7341cdfb5bef6abaf4e12c91d016a940e201e8b7.zip |
SETU: avoid 64-bit shift on 64-bit value.
Shifting a 64-bit value by any more than 63 bits is undefined behavior,
apparently - at least, the sanitizers complain about it. The intuitive,
obvious result, of course, is for the result to be 0. In this case, when s ==
0, x << (64 - s) should result in 0, and (x >> s) should result in x, and the
bitwise-or of those two should be x. Which x already was.
Perhaps it should be investigated whether (x >> (64 - s)) should actually
be (x >> (63 - s)), since 0 <= s < 64.
Signed-off-by: Martin Schanzenbach <schanzen@gnunet.org>
-rw-r--r-- | src/setu/gnunet-service-setu_strata_estimator.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/setu/gnunet-service-setu_strata_estimator.c b/src/setu/gnunet-service-setu_strata_estimator.c index 7981cc847..43ccf3afd 100644 --- a/src/setu/gnunet-service-setu_strata_estimator.c +++ b/src/setu/gnunet-service-setu_strata_estimator.c | |||
@@ -85,7 +85,8 @@ salt_key (const struct IBF_Key *k_in, | |||
85 | uint64_t x = k_in->key_val; | 85 | uint64_t x = k_in->key_val; |
86 | 86 | ||
87 | /* rotate ibf key */ | 87 | /* rotate ibf key */ |
88 | x = (x >> s) | (x << (64 - s)); | 88 | if (s > 0) |
89 | x = (x >> s) | (x << (64 - s)); | ||
89 | k_out->key_val = x; | 90 | k_out->key_val = x; |
90 | } | 91 | } |
91 | 92 | ||