diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2020-03-01 16:41:28 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2020-03-01 16:41:28 +0100 |
commit | c4ef3d6c2e5339d3b6ac2ba255d166a4d8984bce (patch) | |
tree | b36837b6da12cc2e262caf887ab592843d9bda53 /src/plugins/script/script-repo.c | |
parent | 1ae25914588221ece76da2d39ddece16de0c7712 (diff) | |
download | weechat-c4ef3d6c2e5339d3b6ac2ba255d166a4d8984bce.zip |
core: merge functions string_hash_binary and string_hash into a single function string_hash
Diffstat (limited to 'src/plugins/script/script-repo.c')
-rw-r--r-- | src/plugins/script/script-repo.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/plugins/script/script-repo.c b/src/plugins/script/script-repo.c index 26dd7db8b..814bf81e5 100644 --- a/src/plugins/script/script-repo.c +++ b/src/plugins/script/script-repo.c @@ -755,7 +755,8 @@ script_repo_sha512sum_file (const char *filename) { struct stat st; FILE *file; - char *data, *hash; + char *data, hash[512 / 8], hash_hexa[((512 / 8) * 2) + 1]; + int length_hash; if (stat (filename, &st) == -1) return NULL; @@ -773,11 +774,17 @@ script_repo_sha512sum_file (const char *filename) } fclose (file); - hash = weechat_string_hash (data, st.st_size, "sha512"); + if (!weechat_string_hash (data, st.st_size, "sha512", hash, &length_hash)) + { + free (data); + return NULL; + } + weechat_string_base_encode (16, hash, length_hash, hash_hexa); + weechat_string_tolower (hash_hexa); free (data); - return hash; + return strdup (hash_hexa); } /* |