Check if a plugin has a meta section

This commit is contained in:
Maschell
2024-04-27 17:46:06 +02:00
parent 28d77bd1ce
commit 2b29db165c
3 changed files with 9 additions and 0 deletions

View File

@@ -56,6 +56,7 @@ std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(st
uint32_t sec_num = reader.sections.size();
bool hasMetaSection = false;
for (uint32_t i = 0; i < sec_num; ++i) {
ELFIO::section *psec = reader.sections[i];
@@ -72,6 +73,7 @@ std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(st
// Get meta information and check WUPS version:
if (psec->get_name() == ".wups.meta") {
hasMetaSection = true;
const void *sectionData = psec->get_data();
uint32_t sectionSize = psec->get_size();
@@ -118,6 +120,11 @@ std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(st
}
}
}
if (!hasMetaSection) {
DEBUG_FUNCTION_LINE_ERR("File has no \".wups.meta\" section");
error = PLUGIN_PARSE_ERROR_NO_PLUGIN;
return {};
}
pluginInfo.setSize(pluginSize);

View File

@@ -28,6 +28,7 @@
enum PluginParseErrors {
PLUGIN_PARSE_ERROR_NONE,
PLUGIN_PARSE_ERROR_UNKNOWN,
PLUGIN_PARSE_ERROR_NO_PLUGIN,
PLUGIN_PARSE_ERROR_INCOMPATIBLE_VERSION,
PLUGIN_PARSE_ERROR_BUFFER_EMPTY,
PLUGIN_PARSE_ERROR_ELFIO_PARSE_FAILED,