Browse Source

Check plugin version against Rack ABI version before plugin is loaded.

tags/v1.1.4
Andrew Belt 5 years ago
parent
commit
d4586c3481
2 changed files with 7 additions and 5 deletions
  1. +4
    -5
      src/plugin.cpp
  2. +3
    -0
      src/plugin/Plugin.cpp

+ 4
- 5
src/plugin.cpp View File

@@ -114,13 +114,12 @@ static Plugin* loadPlugin(std::string path) {
#endif
}
}
// DEBUG("%lf", plugin->modifiedTimestamp);

// Load plugin.json
std::string metadataFilename = (path == "") ? asset::system("Core.json") : (path + "/plugin.json");
FILE* file = fopen(metadataFilename.c_str(), "r");
std::string manifestFilename = (path == "") ? asset::system("Core.json") : (path + "/plugin.json");
FILE* file = fopen(manifestFilename.c_str(), "r");
if (!file) {
throw UserException(string::f("Metadata file %s does not exist", metadataFilename.c_str()));
throw UserException(string::f("Manifest file %s does not exist", manifestFilename.c_str()));
}
DEFER({
fclose(file);
@@ -129,7 +128,7 @@ static Plugin* loadPlugin(std::string path) {
json_error_t error;
json_t* rootJ = json_loadf(file, 0, &error);
if (!rootJ) {
throw UserException(string::f("JSON parsing error at %s %d:%d %s", metadataFilename.c_str(), error.line, error.column, error.text));
throw UserException(string::f("JSON parsing error at %s %d:%d %s", manifestFilename.c_str(), error.line, error.column, error.text));
}
DEFER({
json_decref(rootJ);


+ 3
- 0
src/plugin/Plugin.cpp View File

@@ -2,6 +2,7 @@
#include <plugin/Model.hpp>
#include <plugin.hpp>
#include <string.hpp>
#include <app/common.hpp>


namespace rack {
@@ -45,6 +46,8 @@ void Plugin::fromJson(json_t* rootJ) {
json_t* versionJ = json_object_get(rootJ, "version");
if (versionJ)
version = json_string_value(versionJ);
if (!string::startsWith(version, app::ABI_VERSION + "."))
throw UserException(string::f("Plugin version %s does not match Rack ABI version %s", version.c_str(), app::ABI_VERSION.c_str()));
if (version == "")
throw UserException("No plugin version");



Loading…
Cancel
Save