Make sure the version of a module is checked.

This commit is contained in:
Maschell 2023-01-03 21:52:44 +01:00
parent 14392b4dc9
commit d6ec92c767
1 changed files with 7 additions and 1 deletions

View File

@ -213,7 +213,8 @@ std::optional<std::shared_ptr<ModuleData>> ModuleDataFactory::load(const std::st
}
}
secInfo = moduleData->getSectionInfo(".wums.meta");
bool checkedVersion = false;
secInfo = moduleData->getSectionInfo(".wums.meta");
if (secInfo && secInfo.value()->getSize() > 0) {
auto *entries = (wums_entry_t *) secInfo.value()->getAddress();
if (entries != nullptr) {
@ -248,6 +249,7 @@ std::optional<std::shared_ptr<ModuleData>> ModuleDataFactory::load(const std::st
moduleData->setInitBeforeRelocationDoneHook(false);
}
} else if (key == "wums" || key == "wum") {
checkedVersion = true;
if (value != "0.3.1") {
DEBUG_FUNCTION_LINE_WARN("Ignoring module - Unsupported WUMS version: %s.", value.c_str());
return std::nullopt;
@ -258,6 +260,10 @@ std::optional<std::shared_ptr<ModuleData>> ModuleDataFactory::load(const std::st
}
}
}
if (!checkedVersion) {
DEBUG_FUNCTION_LINE_ERR("Failed to check version. Ignoring module.");
return {};
}
// Get the symbol for functions.
Elf_Half n = reader.sections.size();