Skip to content

Commit 2a2bc2b

Browse files
committed
Fixed issues on Windows with multi-dll-hash code.
1 parent 81045a0 commit 2a2bc2b

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

analytics/src/analytics_desktop.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void Initialize(const App& app) {
6363
if (!g_analytics_module) {
6464
std::vector<std::string> allowed_hashes;
6565
for (int i=0; i < FirebaseAnalytics_KnownWindowsDllHashCount; i++) {
66-
allowed_hashes.push_back(FirebaseAnalytics_KnownWindowsDllHash[i]);
66+
allowed_hashes.push_back(std::string(FirebaseAnalytics_KnownWindowsDllHashes[i]));
6767
}
6868

6969
g_analytics_module =

analytics/src/analytics_windows.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static std::string CalculateFileSha256(HANDLE hFile) {
204204
}
205205

206206
// Remove the null terminator from the string.
207-
hex_hash_string.resize(hex_string_size - 1);
207+
hex_hash_string.resize(hex_string_size);
208208

209209
// --- Final Cleanup ---
210210
CryptDestroyHash(hHash);
@@ -287,6 +287,9 @@ HMODULE VerifyAndLoadAnalyticsLibrary(
287287
hash_matched = true;
288288
break;
289289
}
290+
else {
291+
LogDebug(LOG_TAG "Hash mismatch: got %s expected %s", calculated_hash.c_str(), expected_hash.c_str());
292+
}
290293
}
291294

292295
if (hash_matched) {

analytics/src/analytics_windows.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <windows.h>
1919

20+
#include <string>
2021
#include <vector>
2122

2223
namespace firebase {
@@ -25,7 +26,7 @@ namespace internal {
2526

2627
HMODULE VerifyAndLoadAnalyticsLibrary(
2728
const wchar_t* library_filename,
28-
const std::vector<std::vector<unsigned char>>& allowed_hashes);
29+
const std::vector<std::string>& allowed_hashes);
2930

3031
} // namespace internal
3132
} // namespace analytics

0 commit comments

Comments
 (0)