Skip to content

Commit

Permalink
Check if a plugin has a meta section
Browse files Browse the repository at this point in the history
  • Loading branch information
Maschell committed Apr 27, 2024
1 parent 28d77bd commit 2b29db1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions source/plugin/PluginMetaInformationFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -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();

Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions source/plugin/PluginMetaInformationFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions source/utils/exports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ extern "C" PluginBackendApiErrorType WUPSGetPluginMetaInformationEx(WUPSBackendG
case PLUGIN_PARSE_ERROR_BUFFER_EMPTY:
case PLUGIN_PARSE_ERROR_ELFIO_PARSE_FAILED:
case PLUGIN_PARSE_ERROR_IO_ERROR:
case PLUGIN_PARSE_ERROR_NO_PLUGIN:
*errOut = PLUGIN_BACKEND_PLUGIN_PARSE_ERROR_UNKNOWN;
break;
}
Expand Down

0 comments on commit 2b29db1

Please sign in to comment.