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) {