summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/script/script-repo.c26
1 files changed, 2 insertions, 24 deletions
diff --git a/src/plugins/script/script-repo.c b/src/plugins/script/script-repo.c
index 89e3deb42..bc0e18e4c 100644
--- a/src/plugins/script/script-repo.c
+++ b/src/plugins/script/script-repo.c
@@ -753,37 +753,15 @@ script_repo_script_is_held (struct t_script_repo *script)
char *
script_repo_sha512sum_file (const char *filename)
{
- struct stat st;
- FILE *file;
- char *data, hash[512 / 8], hash_hexa[((512 / 8) * 2) + 1];
+ char hash[512 / 8], hash_hexa[((512 / 8) * 2) + 1];
int hash_size;
- if (stat (filename, &st) == -1)
- return NULL;
-
- data = malloc (st.st_size);
- if (!data)
- return NULL;
-
- file = fopen (filename, "r");
- if ((int)fread (data, 1, st.st_size, file) < st.st_size)
- {
- free (data);
- fclose (file);
+ if (!weechat_crypto_hash_file (filename, "sha512", hash, &hash_size))
return NULL;
- }
- fclose (file);
- if (!weechat_crypto_hash (data, st.st_size, "sha512", hash, &hash_size))
- {
- free (data);
- return NULL;
- }
weechat_string_base_encode (16, hash, hash_size, hash_hexa);
weechat_string_tolower (hash_hexa);
- free (data);
-
return strdup (hash_hexa);
}