From 19d9b21cd5bb211f4c1fcac094d8967df5acc184 Mon Sep 17 00:00:00 2001 From: Yimura Date: Wed, 23 Feb 2022 01:45:15 +0100 Subject: [PATCH] fix(Remote): Return is version info is valid --- src/Remote.hpp | 3 ++- src/main.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Remote.hpp b/src/Remote.hpp index 0a37784..520d6cb 100644 --- a/src/Remote.hpp +++ b/src/Remote.hpp @@ -9,6 +9,7 @@ namespace Remote const std::string m_Path; const std::string m_Version; const int m_VersionMachine; + const bool m_Valid; }; inline VersionInfo GetVersionInfo(const std::string_view dllProvider) @@ -22,7 +23,7 @@ namespace Remote nlohmann::json j = nlohmann::json::parse(res.body.begin(), res.body.end()); - return { j["file"], j["version"], j["version_machine"] }; + return { j["file"], j["version"], j["version_machine"], true }; } catch (const std::exception&) { diff --git a/src/main.cpp b/src/main.cpp index 733a465..da1812c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,6 +23,13 @@ int main(int argc, const char** argv) dllFile = g.m_WebServer.m_File; const auto versionInfo = Remote::GetVersionInfo(g.m_WebServer.m_DllProvider); + if (!versionInfo.m_Valid) + { + LOG(WARNING) << "Host did not return valid version data, does it have a version.json?"; + + return 1; + } + if (!std::filesystem::exists(dllFile) || g.m_WebServer.m_VersionMachine < versionInfo.m_VersionMachine) { if (!Remote::DownloadBinary(