aboutsummaryrefslogtreecommitdiff
path: root/src/hash/blake2.c
diff options
context:
space:
mode:
authorame <[email protected]>2024-05-01 23:52:54 -0500
committerame <[email protected]>2024-05-01 23:52:54 -0500
commit8740f3685e959d6477230cf4e8f33c7c93f9ea2b (patch)
treefeb939eadc804dfbdcf148c70fa235c36912476b /src/hash/blake2.c
parente59344f2d3903b9643ff8d77064147dfabced117 (diff)
fix some hash ub
Diffstat (limited to 'src/hash/blake2.c')
-rw-r--r--src/hash/blake2.c4
1 files changed, 2 insertions, 2 deletions
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);