From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 34641138334 for ; Sun, 14 Jul 2019 13:09:48 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DE2A2E08A2; Sun, 14 Jul 2019 13:09:46 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id B4775E08AA for ; Sun, 14 Jul 2019 13:09:46 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B8B1C347A95 for ; Sun, 14 Jul 2019 13:09:45 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 5E60D6F2 for ; Sun, 14 Jul 2019 13:09:44 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1563106208.2e4b280488b5f030a6e735060bb73667d1533fab.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: /, libq/ X-VCS-Repository: proj/portage-utils X-VCS-Files: libq/hash.c libq/hash.h qmanifest.c X-VCS-Directories: libq/ / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 2e4b280488b5f030a6e735060bb73667d1533fab X-VCS-Branch: master Date: Sun, 14 Jul 2019 13:09:44 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 71b92b4e-be45-4494-96aa-6ece0e08af8e X-Archives-Hash: 0e858e3c7aff4f29c9fbbebdbbeab95a commit: 2e4b280488b5f030a6e735060bb73667d1533fab Author: Fabian Groffen gentoo org> AuthorDate: Sun Jul 14 12:10:08 2019 +0000 Commit: Fabian Groffen gentoo 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 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!");