aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2017-09-29 19:49:51 +0100
committerJoão Valverde <j@v6e.pt>2017-10-03 10:09:24 +0000
commit2777003e121a5d764b54c62590e7ceb46ae2c157 (patch)
tree1ca9471c447c0fcf94640328fd1a3207224615ad /wsutil
parentd477ea35a946c2935974edb3fea45cf23513a03c (diff)
Add version check for plugin compatibility
Only plugins built for the same feature release (X.Y) are assured binary compatibility. Make sure we don't try to run unsuitable code and, if so, warn the user. This might happen for example if the user manually copies a binary plugin to the wrong folder, intentionally or by accident. I'm using "release version" to loosely mean not a patch release (i.e: a feature release). Change-Id: I896e9cbbd2d3843623fff6af8ef51002ec06f1f8 Reviewed-on: https://code.wireshark.org/review/23807 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: João Valverde <j@v6e.pt>
Diffstat (limited to 'wsutil')
-rw-r--r--wsutil/filesystem.c6
-rw-r--r--wsutil/plugins.c21
2 files changed, 20 insertions, 7 deletions
diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c
index ce1eca773b..8f0a3ead2d 100644
--- a/wsutil/filesystem.c
+++ b/wsutil/filesystem.c
@@ -1066,8 +1066,7 @@ get_plugins_dir_with_version(void)
if (!plugin_dir)
init_plugin_dir();
if (plugin_dir && !plugin_dir_with_version)
- plugin_dir_with_version = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%d.%d",
- plugin_dir, VERSION_MAJOR, VERSION_MINOR);
+ plugin_dir_with_version = g_build_filename(plugin_dir, VERSION_RELEASE, (gchar *)NULL);
return plugin_dir_with_version;
}
@@ -1086,8 +1085,7 @@ get_plugins_pers_dir_with_version(void)
if (!plugin_pers_dir)
init_plugin_pers_dir();
if (plugin_pers_dir && !plugin_pers_dir_with_version)
- plugin_pers_dir_with_version = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%d.%d",
- plugin_pers_dir, VERSION_MAJOR, VERSION_MINOR);
+ plugin_pers_dir_with_version = g_build_filename(plugin_pers_dir, VERSION_RELEASE, (gchar *)NULL);
return plugin_pers_dir_with_version;
}
diff --git a/wsutil/plugins.c b/wsutil/plugins.c
index 62ddf997fd..cde504a24e 100644
--- a/wsutil/plugins.c
+++ b/wsutil/plugins.c
@@ -115,6 +115,7 @@ plugins_scan_dir(const char *dirname, plugin_load_failure_mode mode)
gchar *filename; /* current file name */
GModule *handle; /* handle returned by g_module_open */
gpointer symbol;
+ const char *plug_version, *plug_release;
plugin *new_plug;
gchar *dot;
@@ -182,9 +183,23 @@ plugins_scan_dir(const char *dirname, plugin_load_failure_mode mode)
continue;
}
- if (!g_module_symbol(handle, "version", &symbol))
+ if (!g_module_symbol(handle, "plugin_version", &symbol))
{
- report_failure("The plugin '%s' has no \"version\" symbol", name);
+ report_failure("The plugin '%s' has no \"plugin_version\" symbol", name);
+ g_module_close(handle);
+ continue;
+ }
+ plug_version = (const char *)symbol;
+
+ if (!g_module_symbol(handle, "plugin_release", &symbol))
+ {
+ report_failure("The plugin '%s' has no \"plugin_release\" symbol", name);
+ g_module_close(handle);
+ continue;
+ }
+ plug_release = (const char *)symbol;
+ if (strcmp(plug_release, VERSION_RELEASE) != 0) {
+ report_failure("The plugin '%s' was compiled for Wireshark version %s", name, plug_release);
g_module_close(handle);
continue;
}
@@ -192,7 +207,7 @@ plugins_scan_dir(const char *dirname, plugin_load_failure_mode mode)
new_plug = (plugin *)g_malloc(sizeof(plugin));
new_plug->handle = handle;
new_plug->name = g_strdup(name);
- new_plug->version = (char *)symbol;
+ new_plug->version = plug_version;
new_plug->types = g_string_new(NULL);
/*