aboutsummaryrefslogtreecommitdiff
path: root/src/hash/sha01.c
diff options
context:
space:
mode:
authoramelia squires <[email protected]>2024-09-16 12:16:29 -0500
committeramelia squires <[email protected]>2024-09-16 12:16:29 -0500
commit602818b895fec710b0534b0b8fa7f5e1f57203c2 (patch)
treed1a5a26af92af8fabf12d5095a2d3745431593b4 /src/hash/sha01.c
parent7c757e7ca41cacd1505622dcb48e5657364aa714 (diff)
fix _copy and mem leaks
Diffstat (limited to 'src/hash/sha01.c')
-rw-r--r--src/hash/sha01.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/hash/sha01.c b/src/hash/sha01.c
index 9ba3e6c..1711faa 100644
--- a/src/hash/sha01.c
+++ b/src/hash/sha01.c
@@ -174,11 +174,24 @@ void sha1(uint8_t* a, size_t len, char* out_stream){
free(aa.buffer);
}
-common_hash_clone(sha1);
+//common_hash_clone(sha1);
+lua_common_hash_clone_oargs(sha1, sha1, l_sha1_init(L), {
+ uint8_t* old = b->buffer;
+ *b = *a;
+ b->buffer = old;
+ memcpy(b->buffer, a->buffer, bs * sizeof * b->buffer);
+});
+
lua_common_hash_init_ni(sha1, sha1, sha01_init_l(1, L));
lua_common_hash_update(sha1, sha1);
-common_hash_clone(sha0);
+//common_hash_clone(sha0);
+lua_common_hash_clone_oargs(sha0, sha0, l_sha0_init(L), {
+ uint8_t* old = b->buffer;
+ *b = *a;
+ b->buffer = old;
+ memcpy(b->buffer, a->buffer, bs * sizeof * b->buffer);
+});
lua_common_hash_init_ni(sha0, sha0, sha01_init_l(0, L));
lua_common_hash_update(sha0, sha0);