From 0290fe03f17711a5c69487017f8f420cf8d1fc90 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 29 Mar 2017 04:26:33 +0200 Subject: [PATCH] fixed bug in sha1sum calculation --- lib/utils.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/utils.c b/lib/utils.c index 6b15abbb8..3e4309792 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -437,8 +437,10 @@ int sha1sum(FILE *f, unsigned char *sha1) SHA_CTX c; char buf[512]; ssize_t bytes; + long seek; - rewind(f); /* Rewind the file in order to calculate over the whole file. */ + seek = ftell(f); + fseek(f, 0, SEEK_SET); SHA1_Init(&c); @@ -449,6 +451,8 @@ int sha1sum(FILE *f, unsigned char *sha1) } SHA1_Final(sha1, &c); + + fseek(f, seek, SEEK_SET); return 0; } \ No newline at end of file