Fix intermittent problem with autochunking not being deterministic
authorJonathan Dieter <jdieter@gmail.com>
Tue, 31 Jul 2018 21:08:13 +0000 (22:08 +0100)
committerJonathan Dieter <jdieter@gmail.com>
Tue, 31 Jul 2018 21:08:13 +0000 (22:08 +0100)
Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
src/lib/buzhash/buzhash.c

index c1fc399fe43f5867ace696e754734243c40cadca..3c35f5ee91f31977a053c5c6f1825f81126e2ef5 100644 (file)
@@ -108,16 +108,16 @@ uint32_t buzhash_update (buzHash *b, const char *s, size_t window) {
         b->window[b->window_fill] = *s;
         b->window_fill++;
         if(b->window_fill < b->window_size) {
-            b->h ^= rol32 (buzhash_table[(size_t) (*s)], window - b->window_fill);
+            b->h ^= rol32 (buzhash_table[(uint8_t) (*s)], window - b->window_fill);
             return 1;
         } else {
-            b->h ^= buzhash_table[(size_t) (*s)];
+            b->h ^= buzhash_table[(uint8_t) (*s)];
             return b->h;
         }
     }
     b->h = rol32 (b->h, 1) ^
-           rol32 (buzhash_table[(size_t) b->window[b->window_loc]], b->window_size) ^
-           buzhash_table[(size_t) *s];
+           rol32 (buzhash_table[(uint8_t) b->window[b->window_loc]], b->window_size) ^
+           buzhash_table[(uint8_t) *s];
     b->window[b->window_loc++] = *s;
     b->window_loc %= b->window_size;
     return b->h;