commit: 2e4b280488b5f030a6e735060bb73667d1533fab Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> AuthorDate: Sun Jul 14 12:10:08 2019 +0000 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> CommitDate: Sun Jul 14 12:10:08 2019 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2e4b2804
libq/hash: ensure hash_compute_file operates on hashes requested thinko probably due to extraction from hashgen at some point, pass hashes with the function call, so it operates on the hashes the caller wants it to. Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> libq/hash.c | 5 ++--- libq/hash.h | 2 +- qmanifest.c | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libq/hash.c b/libq/hash.c index 32d047a..6d0a62b 100644 --- a/libq/hash.c +++ b/libq/hash.c @@ -22,8 +22,6 @@ #include "hash.h" -static int hashes = HASH_DEFAULT; - void hash_hex(char *out, const unsigned char *buf, const int length) { @@ -97,7 +95,8 @@ hash_compute_file( char *sha512, char *whrlpl, char *blak2b, - size_t *flen) + size_t *flen, + int hashes) { FILE *f; char data[8192]; diff --git a/libq/hash.h b/libq/hash.h index 157c454..89f3841 100644 --- a/libq/hash.h +++ b/libq/hash.h @@ -21,6 +21,6 @@ enum hash_impls { void hash_hex(char *out, const unsigned char *buf, const int length); void hash_compute_file(const char *fname, char *sha256, char *sha512, - char *whrlpl, char *blak2b, size_t *flen); + char *whrlpl, char *blak2b, size_t *flen, int hashes); #endif diff --git a/qmanifest.c b/qmanifest.c index 21254c3..41faa4c 100644 --- a/qmanifest.c +++ b/qmanifest.c @@ -201,7 +201,7 @@ write_hashes( update_times(tv, &s); - hash_compute_file(fname, sha256, sha512, whrlpl, blak2b, &flen); + hash_compute_file(fname, sha256, sha512, whrlpl, blak2b, &flen, hashes); len = snprintf(data, sizeof(data), "%s %s %zd", type, name, flen); if (hashes & HASH_BLAKE2B) @@ -1027,7 +1027,7 @@ verify_file(const char *dir, char *mfline, const char *mfest, verify_msg **msgs) sha256[0] = sha512[0] = whrlpl[0] = blak2b[0] = '\0'; snprintf(buf, sizeof(buf), "%s/%s", dir, path); - hash_compute_file(buf, sha256, sha512, whrlpl, blak2b, &flen); + hash_compute_file(buf, sha256, sha512, whrlpl, blak2b, &flen, hashes); if (flen == 0) { msgs_add(msgs, mfest, path, "cannot open file!");