diff options
author | Rémy Raes <raes.remy@gmail.com> | 2024-07-10 01:21:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-10 01:21:40 +0200 |
commit | 52b11022997c834efd2b50234e1e664603806503 (patch) | |
tree | 72984a76da6c8513319203a565d6a2c6504b62ad /primedev/mods | |
parent | 497945bbbd18b4ff9cd264dc6a9d6cf8ba6bf08e (diff) | |
download | NorthstarLauncher-52b11022997c834efd2b50234e1e664603806503.tar.gz NorthstarLauncher-52b11022997c834efd2b50234e1e664603806503.zip |
fix: Do not crash on unknown MAD manifesto format (#749)
Verify JSON has attributes before trying to access them
Diffstat (limited to 'primedev/mods')
-rw-r--r-- | primedev/mods/autodownload/moddownloader.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/primedev/mods/autodownload/moddownloader.cpp b/primedev/mods/autodownload/moddownloader.cpp index 3a946263..feaa08ea 100644 --- a/primedev/mods/autodownload/moddownloader.cpp +++ b/primedev/mods/autodownload/moddownloader.cpp @@ -92,6 +92,13 @@ void ModDownloader::FetchModsListFromAPI() verifiedModsJson.Parse(readBuffer); for (auto i = verifiedModsJson.MemberBegin(); i != verifiedModsJson.MemberEnd(); ++i) { + // Format testing + if (!i->value.HasMember("DependencyPrefix") || !i->value.HasMember("Versions")) + { + spdlog::warn("Verified mods manifesto format is unrecognized, skipping loading."); + return; + } + std::string name = i->name.GetString(); std::string dependency = i->value["DependencyPrefix"].GetString(); @@ -101,6 +108,13 @@ void ModDownloader::FetchModsListFromAPI() for (auto& attribute : versions.GetArray()) { assert(attribute.IsObject()); + // Format testing + if (!attribute.HasMember("Version") || !attribute.HasMember("Checksum")) + { + spdlog::warn("Verified mods manifesto format is unrecognized, skipping loading."); + return; + } + std::string version = attribute["Version"].GetString(); std::string checksum = attribute["Checksum"].GetString(); modVersions.insert({version, {.checksum = checksum}}); |