From 41cbab2e55872f4bb62daad0c878684e4bcd847d Mon Sep 17 00:00:00 2001 From: JohnMcPMS Date: Fri, 30 Oct 2026 10:16:59 -0700 Subject: [PATCH] Fix fuzzing build --- src/AppInstallerSharedLib/Hash.cpp | 2 ++ src/AppInstallerSharedLib/Public/winget/Hash.h | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/AppInstallerSharedLib/Hash.cpp b/src/AppInstallerSharedLib/Hash.cpp index e98227cb8c..c1824c18e4 100644 --- a/src/AppInstallerSharedLib/Hash.cpp +++ b/src/AppInstallerSharedLib/Hash.cpp @@ -218,6 +218,7 @@ namespace return targetFileHash; } +#ifndef WINGET_DISABLE_FOR_FUZZING Hash::HashBuffer Hash::ComputeHashFromHandle(HashAlgorithm algorithm, HANDLE fileHandle) { constexpr DWORD bufferSize = 1024 * 1024; @@ -238,6 +239,7 @@ namespace return hasher.Get(); } +#endif bool Hash::AreEqual(const HashBuffer& first, const HashBuffer& second) { diff --git a/src/AppInstallerSharedLib/Public/winget/Hash.h b/src/AppInstallerSharedLib/Public/winget/Hash.h index 152d892a67..bdb43d9664 100644 --- a/src/AppInstallerSharedLib/Public/winget/Hash.h +++ b/src/AppInstallerSharedLib/Public/winget/Hash.h @@ -86,9 +86,11 @@ namespace AppInstaller::Cryptography { // Computes the hash from a given file path. static HashBuffer ComputeHashFromFile(HashAlgorithm algorithm, const std::filesystem::path& path); +#ifndef WINGET_DISABLE_FOR_FUZZING // Computes the hash from an open file HANDLE by reading sequentially from the current position. // The caller retains ownership of the handle. static HashBuffer ComputeHashFromHandle(HashAlgorithm algorithm, HANDLE fileHandle); +#endif static std::string ConvertToString(const HashBuffer& hashBuffer, size_t hashBufferSizeInBytes); @@ -156,10 +158,12 @@ namespace AppInstaller::Cryptography { return Hash::ComputeHashFromFile(Algorithm, path); } +#ifndef WINGET_DISABLE_FOR_FUZZING static HashBuffer ComputeHashFromHandle(HANDLE fileHandle) { return Hash::ComputeHashFromHandle(Algorithm, fileHandle); } +#endif static std::string ConvertToString(const HashBuffer& hashBuffer) {