From 8740f3685e959d6477230cf4e8f33c7c93f9ea2b Mon Sep 17 00:00:00 2001 From: ame Date: Wed, 1 May 2024 23:52:54 -0500 Subject: fix some hash ub --- src/hash/blake2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/hash/blake2.c') diff --git a/src/hash/blake2.c b/src/hash/blake2.c index 61c79ca..9507c96 100644 --- a/src/hash/blake2.c +++ b/src/hash/blake2.c @@ -231,7 +231,7 @@ void blake2b_final(struct blake2b_hash* hash, char* out_stream){ blake2b_round(hash, 1); - for(int i = 0; i != hash->digest_len; i++)sprintf(out_stream, "%s%02x", out_stream, (((uint8_t*)hash->hash)[i])); + for(int i = 0; i != hash->digest_len; i++)sprintf(out_stream + i * 2, "%02x", (((uint8_t*)hash->hash)[i])); memcpy(hash, &old_hash, sizeof * hash); memcpy(hash->buffer, old, bs_2); @@ -363,7 +363,7 @@ void blake2s_final(struct blake2s_hash* hash, char* out_stream){ blake2s_round(hash, 1); - for(int i = 0; i != hash->digest_len; i++)sprintf(out_stream, "%s%02x", out_stream, (((uint8_t*)hash->hash)[i])); + for(int i = 0; i != hash->digest_len; i++)sprintf(out_stream + i * 2, "%02x", (((uint8_t*)hash->hash)[i])); memcpy(hash, &old_hash, sizeof * hash); memcpy(hash->buffer, old, bs); -- cgit v1.2.3