aboutsummaryrefslogtreecommitdiff
path: root/src/hash/blake.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
commit81b85b557c308ff743b7b83f2b823e508eef54eb (patch)
treefeb939eadc804dfbdcf148c70fa235c36912476b /src/hash/blake.c
parent22473687abdbf45c86e837d636cde036845e8460 (diff)
fix some hash ub
Diffstat (limited to 'src/hash/blake.c')
-rw-r--r--src/hash/blake.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/hash/blake.c b/src/hash/blake.c
index c6d73ad..76b6680 100644
--- a/src/hash/blake.c
+++ b/src/hash/blake.c
@@ -215,7 +215,7 @@ void blake256_final(struct blake256_hash* hash, char* out_stream){
_blake256_final(hash, out_stream);
for(int i = 0; i != 8; i++){
- sprintf(out_stream, "%s%08x",out_stream,(hash->hash)[i]);
+ sprintf(out_stream + i * 8, "%08x",(hash->hash)[i]);
}
memcpy(hash, &old_hash, sizeof * hash);
@@ -234,7 +234,7 @@ void blake224_final(struct blake256_hash* hash, char* out_stream){
_blake256_final(hash, out_stream);
for(int i = 0; i != 7; i++){
- sprintf(out_stream, "%s%08x",out_stream,(hash->hash)[i]);
+ sprintf(out_stream + i * 8, "%08x",(hash->hash)[i]);
}
memcpy(hash, &old_hash, sizeof * hash);
@@ -427,8 +427,8 @@ void blake512_final(struct blake512_hash* hash, char* out_stream){
_blake512_final(hash, out_stream);
for(int i = 0; i != 8; i++){
- sprintf(out_stream, "%s%016llx",out_stream, (hash->hash)[i]);
- }
+ sprintf(out_stream + 16 * i, "%016llx", (hash->hash)[i]);
+ }
memcpy(hash, &old_hash, sizeof * hash);
memcpy(hash->buffer, old, bs_2);
@@ -454,8 +454,8 @@ void blake384_final(struct blake384_hash* hash, char* out_stream){
_blake512_final(hash, out_stream);
for(int i = 0; i != 6; i++){
- sprintf(out_stream, "%s%016llx",out_stream, (hash->hash)[i]);
- }
+ sprintf(out_stream + 16 * i, "%016llx", (hash->hash)[i]);
+ }
memcpy(hash, &old_hash, sizeof * hash);
memcpy(hash->buffer, old, bs_2);