From f7cd59d7578739849d1b11cd18255c6682007bd4 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Fri, 12 Jul 2024 11:35:56 +0200 Subject: Use a fixed HashFunction in install_cas ...to calculate the empty compatible hash. --- src/buildtool/main/install_cas.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/buildtool/main/install_cas.cpp') diff --git a/src/buildtool/main/install_cas.cpp b/src/buildtool/main/install_cas.cpp index 8af7a2df..3c460200 100644 --- a/src/buildtool/main/install_cas.cpp +++ b/src/buildtool/main/install_cas.cpp @@ -32,7 +32,10 @@ namespace { [[nodiscard]] auto InvalidSizeString(std::string const& size_str, std::string const& hash, bool has_remote) noexcept -> bool { - static auto const kEmptyHash = HashFunction::Instance().ComputeBlobHash(""); + // Only in compatible mode the size is checked, so an empty SHA256 hash is + // needed. + static auto const kEmptyHash = + HashFunction{HashFunction::JustHash::Compatible}.ComputeBlobHash(""); return Compatibility::IsCompatible() and // native mode is fine (size_str == "0" or size_str.empty()) and // not "0" or "" is fine kEmptyHash.HexString() != hash and // empty hash is fine -- cgit v1.2.3