Browse Source

siphash: Use ~7 correctly

7 in ~7 needs to be size_t for it to be correct when len > INT_MAX.
Ulrik Sverdrup 13 years ago
parent
commit
c6b3ef74f4
1 changed files with 1 additions and 1 deletions
  1. 1 1
      ccan/siphash/siphash.c

+ 1 - 1
ccan/siphash/siphash.c

@@ -45,7 +45,7 @@ static void siphash_init(u64 v[5], const unsigned char key[16])
 /* Load the last 0-7 bytes of `in` and put in len & 255 */
 /* Load the last 0-7 bytes of `in` and put in len & 255 */
 static void siphash_epilogue(u64 *m, const unsigned char *in, size_t len)
 static void siphash_epilogue(u64 *m, const unsigned char *in, size_t len)
 {
 {
-    in += (len & ~7);
+    in += len & ~(size_t)7;
     *m = (u64)(len & 255) << 56;
     *m = (u64)(len & 255) << 56;
     switch (len & 7) {
     switch (len & 7) {
         case 7: *m |= (u64) in[6] << 48;
         case 7: *m |= (u64) in[6] << 48;