aboutsummaryrefslogtreecommitdiff
path: root/core/hash
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2022-05-01 12:54:20 +0200
committerGitHub <noreply@github.com>2022-05-01 12:54:20 +0200
commitdf233aee942bd85a5162a36a82bf33fe74d2f2ad (patch)
tree15527d85c40e07f328e3644e899e2483a67239b1 /core/hash
parent6ade9acc4d220a9912fb7d88ae26d82131351e12 (diff)
parent335b7242099153f0777ce5417b8ef8261de03ec8 (diff)
Merge pull request #1760 from Kelimion/xxh3_fixdev-2022-05
[xxh3] Fix flaws in streaming implementation
Diffstat (limited to 'core/hash')
-rw-r--r--core/hash/xxhash/streaming.odin8
1 files changed, 4 insertions, 4 deletions
diff --git a/core/hash/xxhash/streaming.odin b/core/hash/xxhash/streaming.odin
index d6df1089f..68a4920a5 100644
--- a/core/hash/xxhash/streaming.odin
+++ b/core/hash/xxhash/streaming.odin
@@ -52,9 +52,6 @@ XXH3_128_reset_with_seed :: proc(state: ^XXH3_state, seed: XXH64_hash) -> (err:
XXH3_64_reset_with_seed :: XXH3_128_reset_with_seed
XXH3_128_update :: proc(state: ^XXH3_state, input: []u8) -> (err: Error) {
- if len(input) < XXH3_MIDSIZE_MAX {
- return .Error
- }
return XXH3_update(state, input, XXH3_accumulate_512, XXH3_scramble_accumulator)
}
XXH3_64_update :: XXH3_128_update
@@ -127,6 +124,7 @@ XXH3_create_state :: proc(allocator := context.allocator) -> (res: ^XXH3_state,
err = nil if mem_error == nil else .Error
XXH3_init_state(state)
+ XXH3_128_reset(state)
return state, nil
}
@@ -234,7 +232,9 @@ XXH3_update :: #force_inline proc(
*/
if state.buffered_size > 0 {
load_size := int(XXH3_INTERNAL_BUFFER_SIZE - state.buffered_size)
- mem_copy(&state.buffer[state.buffered_size], &input[0], load_size)
+
+ state_ptr := rawptr(uintptr(raw_data(state.buffer[:])) + uintptr(state.buffered_size))
+ mem_copy(state_ptr, raw_data(input), load_size)
input = input[load_size:]
XXH3_consume_stripes(