From 808352e5473f90b4042370e037788d3793f4b8c3 Mon Sep 17 00:00:00 2001 From: Alberto Sartori Date: Wed, 15 Nov 2023 16:08:18 +0100 Subject: just-execute: verify the validity of all the hashes received over the wire --- src/buildtool/execution_api/execution_service/cas_server.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/buildtool/execution_api/execution_service/cas_server.cpp') diff --git a/src/buildtool/execution_api/execution_service/cas_server.cpp b/src/buildtool/execution_api/execution_service/cas_server.cpp index 65cb5c92..abdab5b1 100644 --- a/src/buildtool/execution_api/execution_service/cas_server.cpp +++ b/src/buildtool/execution_api/execution_service/cas_server.cpp @@ -17,14 +17,17 @@ #include "fmt/core.h" #include "src/buildtool/compatibility/native_support.hpp" #include "src/buildtool/storage/garbage_collector.hpp" +#include "src/utils/cpp/verify_hash.hpp" static constexpr std::size_t kJustHashLength = 42; static constexpr std::size_t kSHA256Length = 64; static auto IsValidHash(std::string const& x) -> bool { + auto error_msg = IsAHash(x); auto const& length = x.size(); - return (Compatibility::IsCompatible() and length == kSHA256Length) or - length == kJustHashLength; + return !error_msg and + ((Compatibility::IsCompatible() and length == kSHA256Length) or + length == kJustHashLength); } auto CASServiceImpl::FindMissingBlobs( -- cgit v1.2.3