diff options
author | ailin-nemui <ailin-nemui@users.noreply.github.com> | 2015-11-24 00:08:20 +0100 |
---|---|---|
committer | ailin-nemui <ailin-nemui@users.noreply.github.com> | 2015-12-10 00:52:33 +0100 |
commit | ff8ccaf08b60d88a67ddf810f8229f910f016cf7 (patch) | |
tree | 8d3e97cca2d679f04be14bc343a14ce7d4c77a28 /src/core/modules-load.c | |
parent | 4dc2bab4b4ae7ff05220c1121f0f11097f77b265 (diff) | |
download | irssi-ff8ccaf08b60d88a67ddf810f8229f910f016cf7.zip |
module check irssi version
Add explicit checks into every module to match the ABI version defined
in common.h
Diffstat (limited to 'src/core/modules-load.c')
-rw-r--r-- | src/core/modules-load.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/core/modules-load.c b/src/core/modules-load.c index 6086d9ae..9baac1d7 100644 --- a/src/core/modules-load.c +++ b/src/core/modules-load.c @@ -160,11 +160,14 @@ static int module_load_name(const char *path, const char *rootmodule, { void (*module_init) (void); void (*module_deinit) (void); + void (*module_version) (int *); GModule *gmodule; MODULE_REC *module; MODULE_FILE_REC *rec; + gpointer value_version = NULL; gpointer value1, value2 = NULL; - char *initfunc, *deinitfunc; + char *versionfunc, *initfunc, *deinitfunc; + int module_abi_version = 0; int found; gmodule = module_open(path, &found); @@ -176,6 +179,27 @@ static int module_load_name(const char *path, const char *rootmodule, return found ? 0 : -1; } + /* get the module's irssi abi version and bail out on mismatch */ + versionfunc = module_get_func(rootmodule, submodule, "abicheck"); + if (!g_module_symbol(gmodule, versionfunc, &value_version)) { + g_free(versionfunc); + module_error(MODULE_ERROR_VERSION_MISMATCH, "0", + rootmodule, submodule); + g_module_close(gmodule); + return 0; + } + g_free(versionfunc); + module_version = value_version; + module_version(&module_abi_version); + if (module_abi_version != IRSSI_ABI_VERSION) { + char *module_abi_versionstr = g_strdup_printf("%d", module_abi_version); + module_error(MODULE_ERROR_VERSION_MISMATCH, module_abi_versionstr, + rootmodule, submodule); + g_free(module_abi_versionstr); + g_module_close(gmodule); + return 0; + } + /* get the module's init() and deinit() functions */ initfunc = module_get_func(rootmodule, submodule, "init"); deinitfunc = module_get_func(rootmodule, submodule, "deinit"); |