From 747b78aff3934f1f20d41b8694b58610aef5ccdc Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sat, 2 May 2009 22:56:14 +0200 Subject: [PATCH] Add API version string: do not load plugins with wrong API version (fix crash when loading old/obsolete plugins) --- po/cs.po | 9 ++++++++- po/de.po | 10 +++++++++- po/es.po | 10 +++++++++- po/fr.po | 12 ++++++++++-- po/hu.po | 10 +++++++++- po/pl.po | 8 +++++++- po/ru.po | 9 ++++++++- po/weechat.pot | 8 +++++++- src/plugins/plugin.c | 33 ++++++++++++++++++++++++++++++--- src/plugins/weechat-plugin.h | 8 ++++++-- 10 files changed, 103 insertions(+), 14 deletions(-) diff --git a/po/cs.po b/po/cs.po index b5814db6b..c8effe147 100644 --- a/po/cs.po +++ b/po/cs.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-04-29 14:30+0200\n" +"POT-Creation-Date: 2009-05-02 22:43+0200\n" "PO-Revision-Date: 2009-01-03 00:42+0100\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -4889,6 +4889,13 @@ msgid "%sError: symbol \"%s\" not found in plugin \"%s\", failed to load" msgstr "" "%s symbol \"plugin_name\" nebyl v pluginu \"%s\" nalezen, načtení selhalo\n" +#, fuzzy, c-format +msgid "" +"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: \"%" +"s\"), failed to load" +msgstr "" +"%s symbol \"plugin_name\" nebyl v pluginu \"%s\" nalezen, načtení selhalo\n" + #, fuzzy, c-format msgid "" "%sError: unable to load plugin \"%s\": a plugin with same name already exists" diff --git a/po/de.po b/po/de.po index dfdd7239a..d8b940f18 100644 --- a/po/de.po +++ b/po/de.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-04-29 14:30+0200\n" +"POT-Creation-Date: 2009-05-02 22:43+0200\n" "PO-Revision-Date: 2009-01-03 00:42+0100\n" "Last-Translator: Thomas Schuetz \n" "Language-Team: weechat-dev \n" @@ -4841,6 +4841,14 @@ msgstr "" "%s Symbol \"plugin_name\" in Plugin \"%s\" nicht gefunden, Laden " "gescheitert\n" +#, fuzzy, c-format +msgid "" +"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: \"%" +"s\"), failed to load" +msgstr "" +"%s Symbol \"plugin_name\" in Plugin \"%s\" nicht gefunden, Laden " +"gescheitert\n" + #, fuzzy, c-format msgid "" "%sError: unable to load plugin \"%s\": a plugin with same name already exists" diff --git a/po/es.po b/po/es.po index b6643df25..d3c051f95 100644 --- a/po/es.po +++ b/po/es.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-04-29 14:30+0200\n" +"POT-Creation-Date: 2009-05-02 22:43+0200\n" "PO-Revision-Date: 2009-01-03 00:42+0100\n" "Last-Translator: Roberto González Cardenete \n" "Language-Team: weechat-dev \n" @@ -4829,6 +4829,14 @@ msgstr "" "%s símbolo \"plugin_name\" no encontrado en el plugin \"%s\", falló al " "cargar\n" +#, fuzzy, c-format +msgid "" +"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: \"%" +"s\"), failed to load" +msgstr "" +"%s símbolo \"plugin_name\" no encontrado en el plugin \"%s\", falló al " +"cargar\n" + #, fuzzy, c-format msgid "" "%sError: unable to load plugin \"%s\": a plugin with same name already exists" diff --git a/po/fr.po b/po/fr.po index c2146e3b3..3f1fb21e3 100644 --- a/po/fr.po +++ b/po/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-04-29 14:30+0200\n" -"PO-Revision-Date: 2009-04-29 14:30+0200\n" +"POT-Creation-Date: 2009-05-02 22:43+0200\n" +"PO-Revision-Date: 2009-05-02 22:44+0200\n" "Last-Translator: FlashCode \n" "Language-Team: weechat-dev \n" "MIME-Version: 1.0\n" @@ -5009,6 +5009,14 @@ msgstr "" "%sErreur: le symbole \"%s\" n'existe pas dans l'extension \"%s\", échec de " "chargement" +#, c-format +msgid "" +"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: \"%" +"s\"), failed to load" +msgstr "" +"%sErreur: API non concordante pour l'extension \"%s\" (API courante: \"%s\", " +"API extension: \"%s\"), échec de chargement" + #, c-format msgid "" "%sError: unable to load plugin \"%s\": a plugin with same name already exists" diff --git a/po/hu.po b/po/hu.po index 33090132c..b5f51878d 100644 --- a/po/hu.po +++ b/po/hu.po @@ -12,7 +12,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-04-29 14:30+0200\n" +"POT-Creation-Date: 2009-05-02 22:43+0200\n" "PO-Revision-Date: 2009-01-03 00:42+0100\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -4899,6 +4899,14 @@ msgstr "" "%s a \"plugin_name\" szimbólum nem található a \"%s\" modulban, betöltés " "sikertelen\n" +#, fuzzy, c-format +msgid "" +"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: \"%" +"s\"), failed to load" +msgstr "" +"%s a \"plugin_name\" szimbólum nem található a \"%s\" modulban, betöltés " +"sikertelen\n" + #, fuzzy, c-format msgid "" "%sError: unable to load plugin \"%s\": a plugin with same name already exists" diff --git a/po/pl.po b/po/pl.po index e104b21f8..5dd3f7db8 100644 --- a/po/pl.po +++ b/po/pl.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-04-29 14:30+0200\n" +"POT-Creation-Date: 2009-05-02 22:43+0200\n" "PO-Revision-Date: 2009-04-29 08:07+0200\n" "Last-Translator: \n" "Language-Team: Polish\n" @@ -4222,6 +4222,12 @@ msgstr "" msgid "%sError: symbol \"%s\" not found in plugin \"%s\", failed to load" msgstr "" +#, c-format +msgid "" +"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: \"%" +"s\"), failed to load" +msgstr "" + #, c-format msgid "" "%sError: unable to load plugin \"%s\": a plugin with same name already exists" diff --git a/po/ru.po b/po/ru.po index bbf7bf6ef..3a82c99df 100644 --- a/po/ru.po +++ b/po/ru.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-04-29 14:30+0200\n" +"POT-Creation-Date: 2009-05-02 22:43+0200\n" "PO-Revision-Date: 2009-01-03 00:42+0100\n" "Last-Translator: Pavel Shevchuk \n" "Language-Team: weechat-dev \n" @@ -4874,6 +4874,13 @@ msgid "%sError: symbol \"%s\" not found in plugin \"%s\", failed to load" msgstr "" "%s символ \"plugin_name\" не найден в plugin'е \"%s\", загрузка не удалась\n" +#, fuzzy, c-format +msgid "" +"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: \"%" +"s\"), failed to load" +msgstr "" +"%s символ \"plugin_name\" не найден в plugin'е \"%s\", загрузка не удалась\n" + #, fuzzy, c-format msgid "" "%sError: unable to load plugin \"%s\": a plugin with same name already exists" diff --git a/po/weechat.pot b/po/weechat.pot index c3d41bf80..ff8dae6c7 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-04-29 14:30+0200\n" +"POT-Creation-Date: 2009-05-02 22:43+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -4185,6 +4185,12 @@ msgstr "" msgid "%sError: symbol \"%s\" not found in plugin \"%s\", failed to load" msgstr "" +#, c-format +msgid "" +"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: \"%" +"s\"), failed to load" +msgstr "" + #, c-format msgid "" "%sError: unable to load plugin \"%s\": a plugin with same name already exists" diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index ec7f4f12b..d5d751f94 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -155,8 +155,8 @@ plugin_load (const char *filename) { char *ptr_home, *full_name, *full_name2; void *handle; - char *name, *author, *description, *version, *weechat_version, *license; - char *charset; + char *name, *api_version, *author, *description, *version; + char *weechat_version, *license, *charset; t_weechat_init_func *init_func; int rc, i, argc; char **argv; @@ -206,6 +206,34 @@ plugin_load (const char *filename) return NULL; } + /* look for API version */ + api_version = dlsym (handle, "weechat_plugin_api_version"); + if (!api_version) + { + gui_chat_printf (NULL, + _("%sError: symbol \"%s\" not found in " + "plugin \"%s\", failed to load"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], + "weechat_plugin_api_version", + full_name); + dlclose (handle); + free (full_name); + return NULL; + } + if (strcmp (api_version, WEECHAT_PLUGIN_API_VERSION) != 0) + { + gui_chat_printf (NULL, + _("%sError: API mismatch for plugin \"%s\" (current " + "API: \"%s\", plugin API: \"%s\"), failed to load"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], + full_name, + WEECHAT_PLUGIN_API_VERSION, + api_version); + dlclose (handle); + free (full_name); + return NULL; + } + /* check for plugin with same name */ if (plugin_search (name)) { @@ -278,7 +306,6 @@ plugin_load (const char *filename) free (full_name); return NULL; } - if (util_weechat_version_cmp (PACKAGE_VERSION, weechat_version) != 0) { gui_chat_printf (NULL, diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 19bfd25ae..9af6bbe16 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -32,9 +32,13 @@ struct t_gui_completion; struct t_infolist; struct t_weelist; +/* API version (used to check that plugin has same API and can be loaded) */ +#define WEECHAT_PLUGIN_API_VERSION "20090502-01" + /* macros for defining plugin infos */ -#define WEECHAT_PLUGIN_NAME(__name) \ - char weechat_plugin_name[] = __name; +#define WEECHAT_PLUGIN_NAME(__name) \ + char weechat_plugin_name[] = __name; \ + char weechat_plugin_api_version[] = WEECHAT_PLUGIN_API_VERSION; #define WEECHAT_PLUGIN_AUTHOR(__author) \ char weechat_plugin_author[] = __author; #define WEECHAT_PLUGIN_DESCRIPTION(__desc) \