bool LLUpdateDownloader::Implementation::validateDownload(const std::string& filePath) { llifstream fileStream(filePath.c_str(), std::ios_base::in | std::ios_base::binary); if(!fileStream) { LL_INFOS("UpdaterService") << "can't open " << filePath << ", invalid" << LL_ENDL; return false; } std::string hash = mDownloadData["hash"].asString(); if (! hash.empty()) { char digest[33]; LLMD5(fileStream).hex_digest(digest); if (hash == digest) { LL_INFOS("UpdaterService") << "verified hash " << hash << " for downloaded " << filePath << LL_ENDL; return true; } else { LL_WARNS("UpdaterService") << "download hash mismatch for " << filePath << ": expected " << hash << " but computed " << digest << LL_ENDL; return false; } } else { LL_INFOS("UpdaterService") << "no hash specified for " << filePath << ", unverified" << LL_ENDL; return true; // No hash check provided. } }
bool LLUpdateDownloader::Implementation::validateDownload(void) { std::string filePath = mDownloadData["path"].asString(); llifstream fileStream(filePath, std::ios_base::in | std::ios_base::binary); if(!fileStream) return false; std::string hash = mDownloadData["hash"].asString(); if(hash.size() != 0) { LL_INFOS("UpdateDownload") << "checking hash..." << LL_ENDL; char digest[33]; LLMD5(fileStream).hex_digest(digest); if(hash != digest) { LL_WARNS("UpdateDownload") << "download hash mismatch; expeted " << hash << " but download is " << digest << LL_ENDL; } return hash == digest; } else { return true; // No hash check provided. } }