1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-10 03:33:12 +02:00

Check plugin version when loading it, to prevent crash when loading old plugins

This commit is contained in:
Sebastien Helleu
2008-03-23 11:41:09 +01:00
parent 61ca929728
commit d9a4bdf629
40 changed files with 289 additions and 127 deletions
+2 -5
View File
@@ -19,10 +19,6 @@
/* alias.c: Alias plugin for WeeChat */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
@@ -33,7 +29,8 @@
WEECHAT_PLUGIN_NAME("alias");
WEECHAT_PLUGIN_DESCRIPTION("Alias plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION("0.1");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_LICENSE("GPL");
struct t_weechat_plugin *weechat_alias_plugin = NULL;
+3 -1
View File
@@ -18,6 +18,7 @@
/* aspell.c: Aspell plugin support for WeeChat */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -31,7 +32,8 @@
WEECHAT_PLUGIN_NAME("aspell");
WEECHAT_PLUGIN_DESCRIPTION("Aspell plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION("0.1");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
WEECHAT_LICENSE("GPL");
struct t_weechat_plugin *weechat_aspell_plugin = NULL;
+4 -1
View File
@@ -21,7 +21,9 @@
#include <stdio.h>
#include <stdlib.h>
#ifndef __USE_GNU
#define __USE_GNU
#endif
#include <string.h>
#include <iconv.h>
@@ -32,7 +34,8 @@
WEECHAT_PLUGIN_NAME("charset");
WEECHAT_PLUGIN_DESCRIPTION("Charset plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION("0.1");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_LICENSE("GPL");
struct t_weechat_plugin *weechat_charset_plugin = NULL;
+2 -5
View File
@@ -19,10 +19,6 @@
/* debug.c: Debug plugin for WeeChat */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
@@ -32,7 +28,8 @@
WEECHAT_PLUGIN_NAME("debug");
WEECHAT_PLUGIN_DESCRIPTION("Debug plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION("0.1");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_LICENSE("GPL");
struct t_weechat_plugin *weechat_debug_plugin = NULL;
+2 -5
View File
@@ -19,10 +19,6 @@
/* demo.c: demo plugin for WeeChat */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
@@ -38,7 +34,8 @@
WEECHAT_PLUGIN_NAME("demo");
WEECHAT_PLUGIN_DESCRIPTION("Demo plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION("0.1");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_LICENSE("GPL");
struct t_weechat_plugin *weechat_demo_plugin = NULL;
+2 -5
View File
@@ -19,10 +19,6 @@
/* fifo.c: FIFO pipe plugin for WeeChat remote control */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
@@ -37,7 +33,8 @@
WEECHAT_PLUGIN_NAME("fifo");
WEECHAT_PLUGIN_DESCRIPTION("Fifo plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION("0.1");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_LICENSE("GPL");
struct t_weechat_plugin *weechat_fifo_plugin = NULL;
-4
View File
@@ -19,10 +19,6 @@
/* irc-buffer.c: manages buffers for IRC protocol */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
-4
View File
@@ -19,10 +19,6 @@
/* irc-channel.c: manages a chat (channel or private chat) */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
-4
View File
@@ -19,10 +19,6 @@
/* irc-color.c: IRC color decoding/encidong in messages */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
-4
View File
@@ -19,10 +19,6 @@
/* irc-command.c: IRC commands managment */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-4
View File
@@ -19,10 +19,6 @@
/* irc-command.c: IRC commands managment */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-4
View File
@@ -19,10 +19,6 @@
/* irc-config.c: IRC configuration options */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
-4
View File
@@ -19,10 +19,6 @@
/* irc-dcc.c: Direct Client-to-Client (DCC) communication (files & chat) */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
-4
View File
@@ -19,10 +19,6 @@
/* irc-debug.c: debug functions for IRC plugin */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
-4
View File
@@ -19,10 +19,6 @@
/* irc-display.c: display functions for IRC */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
-4
View File
@@ -19,10 +19,6 @@
/* irc-input.c: IRC input data (read from user) */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
-4
View File
@@ -19,10 +19,6 @@
/* irc-mode.c: IRC channel/user modes management */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
-4
View File
@@ -19,10 +19,6 @@
/* irc-nick.c: manages nick list for channels */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-4
View File
@@ -20,10 +20,6 @@
2811 2812 */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef __USE_XOPEN
#define __USE_XOPEN
#endif
-4
View File
@@ -19,10 +19,6 @@
/* irc-server.c: connection and communication with IRC server */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
+2 -5
View File
@@ -19,10 +19,6 @@
/* irc.c: IRC plugin for WeeChat */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
@@ -45,7 +41,8 @@
WEECHAT_PLUGIN_NAME("irc");
WEECHAT_PLUGIN_DESCRIPTION("IRC (Internet Relay Chat) plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION("0.1");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_LICENSE("GPL");
struct t_weechat_plugin *weechat_irc_plugin = NULL;
+4 -3
View File
@@ -19,8 +19,8 @@
/* logger.c: Logger plugin for WeeChat */
#ifdef HAVE_CONFIG_H
#include "config.h"
#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif
#include <stdlib.h>
@@ -42,7 +42,8 @@
WEECHAT_PLUGIN_NAME("logger");
WEECHAT_PLUGIN_DESCRIPTION("Logger plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION("0.1");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_LICENSE("GPL");
struct t_weechat_plugin *weechat_logger_plugin = NULL;
+44 -10
View File
@@ -86,7 +86,8 @@ plugin_load (char *filename)
{
char *full_name;
void *handle;
char *name, *author, *description, *version, *license, *charset;
char *name, *author, *description, *version, *weechat_version, *license;
char *charset;
t_weechat_init_func *init_func;
int rc;
struct t_weechat_plugin *new_plugin;
@@ -114,13 +115,13 @@ plugin_load (char *filename)
name = dlsym (handle, "weechat_plugin_name");
if (!name)
{
dlclose (handle);
gui_chat_printf (NULL,
_("%sError: symbol \"%s\" not found in "
"plugin \"%s\", failed to load"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
"weechat_plugin_name",
full_name);
dlclose (handle);
free (full_name);
return NULL;
}
@@ -128,12 +129,12 @@ plugin_load (char *filename)
/* check for plugin with same name */
if (plugin_search (name))
{
dlclose (handle);
gui_chat_printf (NULL,
_("%sError: unable to load plugin \"%s\": a plugin "
"with same name already exists"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
full_name);
dlclose (handle);
free (full_name);
return NULL;
}
@@ -142,13 +143,13 @@ plugin_load (char *filename)
description = dlsym (handle, "weechat_plugin_description");
if (!description)
{
dlclose (handle);
gui_chat_printf (NULL,
_("%sError: symbol \"%s\" not found "
"in plugin \"%s\", failed to load"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
"weechat_plugin_description",
full_name);
dlclose (handle);
free (full_name);
return NULL;
}
@@ -157,13 +158,13 @@ plugin_load (char *filename)
author = dlsym (handle, "weechat_plugin_author");
if (!author)
{
dlclose (handle);
gui_chat_printf (NULL,
_("%sError: symbol \"%s\" not found "
"in plugin \"%s\", failed to load"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
"weechat_plugin_author",
full_name);
dlclose (handle);
free (full_name);
return NULL;
}
@@ -172,28 +173,57 @@ plugin_load (char *filename)
version = dlsym (handle, "weechat_plugin_version");
if (!version)
{
dlclose (handle);
gui_chat_printf (NULL,
_("%sError: symbol \"%s\" not found in "
"plugin \"%s\", failed to load"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
"weechat_plugin_version",
full_name);
dlclose (handle);
free (full_name);
return NULL;
}
/* look for WeeChat version required for plugin */
weechat_version = dlsym (handle, "weechat_plugin_weechat_version");
if (!weechat_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_weechat_version",
full_name);
dlclose (handle);
free (full_name);
return NULL;
}
if (util_weechat_version_cmp (PACKAGE_VERSION, weechat_version) != 0)
{
gui_chat_printf (NULL,
_("%sError: plugin \"%s\" is compiled for WeeChat "
"%s and you are running version %s, failed to "
"load"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
full_name,
weechat_version, PACKAGE_VERSION);
dlclose (handle);
free (full_name);
return NULL;
}
/* look for plugin license */
license = dlsym (handle, "weechat_plugin_license");
if (!license)
{
dlclose (handle);
gui_chat_printf (NULL,
_("%sError: symbol \"%s\" not found in "
"plugin \"%s\", failed to load"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
"weechat_plugin_license",
full_name);
dlclose (handle);
free (full_name);
return NULL;
}
@@ -205,13 +235,13 @@ plugin_load (char *filename)
init_func = dlsym (handle, "weechat_plugin_init");
if (!init_func)
{
dlclose (handle);
gui_chat_printf (NULL,
_("%sError: function \"%s\" not "
"found in plugin \"%s\", failed to load"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
"weechat_plugin_init",
full_name);
dlclose (handle);
free (full_name);
return NULL;
}
@@ -227,6 +257,7 @@ plugin_load (char *filename)
new_plugin->description = strdup (description);
new_plugin->author = strdup (author);
new_plugin->version = strdup (version);
new_plugin->weechat_version = strdup (weechat_version);
new_plugin->license = strdup (license);
new_plugin->charset = (charset) ? strdup (charset) : NULL;
@@ -397,14 +428,15 @@ plugin_load (char *filename)
"(not enough memory)"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
full_name);
dlclose (handle);
free (full_name);
return NULL;
}
gui_chat_printf (NULL,
_("%sPlugin \"%s\" %s loaded"),
_("%sPlugin \"%s\" loaded"),
gui_chat_prefix[GUI_CHAT_PREFIX_INFO],
name, new_plugin->version);
name);
free (full_name);
@@ -570,6 +602,8 @@ plugin_remove (struct t_weechat_plugin *plugin)
free (plugin->author);
if (plugin->version)
free (plugin->version);
if (plugin->weechat_version)
free (plugin->weechat_version);
if (plugin->license)
free (plugin->license);
if (plugin->charset)
+2 -1
View File
@@ -35,7 +35,8 @@
WEECHAT_PLUGIN_NAME("lua");
WEECHAT_PLUGIN_DESCRIPTION("Lua plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION("0.1");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_LICENSE("GPL");
struct t_weechat_plugin *weechat_lua_plugin;
+2 -1
View File
@@ -33,7 +33,8 @@
WEECHAT_PLUGIN_NAME("perl");
WEECHAT_PLUGIN_DESCRIPTION("Perl plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION("0.1");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_LICENSE("GPL");
struct t_weechat_plugin *weechat_perl_plugin = NULL;
+2 -1
View File
@@ -31,7 +31,8 @@
WEECHAT_PLUGIN_NAME("python");
WEECHAT_PLUGIN_DESCRIPTION("Python plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION("0.1");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_LICENSE("GPL");
struct t_weechat_plugin *weechat_python_plugin = NULL;
+2 -1
View File
@@ -34,7 +34,8 @@
WEECHAT_PLUGIN_NAME("ruby");
WEECHAT_PLUGIN_DESCRIPTION("Ruby plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION("0.1");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_LICENSE("GPL");
struct t_weechat_plugin *weechat_ruby_plugin = NULL;
+3 -1
View File
@@ -18,6 +18,7 @@
/* weechat-trigger.c: Trigger plugin for WeeChat */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -31,7 +32,8 @@
WEECHAT_PLUGIN_NAME("trigger");
WEECHAT_PLUGIN_DESCRIPTION("Trigger plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION("0.1");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_LICENSE("GPL");
t_weechat_trigger *weechat_trigger_list = NULL;
+4 -1
View File
@@ -38,6 +38,8 @@ struct t_weelist;
char weechat_plugin_description[] = __desc;
#define WEECHAT_PLUGIN_VERSION(__version) \
char weechat_plugin_version[] = __version;
#define WEECHAT_PLUGIN_WEECHAT_VERSION(__version) \
char weechat_plugin_weechat_version[] = __version;
#define WEECHAT_PLUGIN_LICENSE(__license) \
char weechat_plugin_license[] = __license;
@@ -69,7 +71,8 @@ struct t_weechat_plugin
char *name; /* short name */
char *description; /* description */
char *author; /* author */
char *version; /* version */
char *version; /* plugin version */
char *weechat_version; /* weechat version required */
char *license; /* license */
char *charset; /* charset used by plugin */
struct t_weechat_plugin *prev_plugin; /* link to previous plugin */