mirror of
https://github.com/weechat/weechat.git
synced 2026-06-28 13:56:37 +02:00
Fix crash when adding rmodifier with invalid regex
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
WeeChat ChangeLog
|
||||
=================
|
||||
Sébastien Helleu <flashcode@flashtux.org>
|
||||
v0.3.5-dev, 2011-02-22
|
||||
v0.3.5-dev, 2011-02-23
|
||||
|
||||
|
||||
Version 0.3.5 (under dev!)
|
||||
--------------------------
|
||||
|
||||
* core: fix crash when adding rmodifier with invalid regex
|
||||
* core: fix crash when using column filling in bars with some empty items
|
||||
(bug #32565)
|
||||
* core: allow relative size for command /window resize
|
||||
|
||||
@@ -128,7 +128,7 @@ rmodifier_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
_("%sError: missing arguments for \"%s\" "
|
||||
"command"),
|
||||
weechat_prefix ("error"), "rmodifier");
|
||||
return WEECHAT_RC_ERROR;
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
ptr_rmodifier = rmodifier_new (argv[2], argv[3], argv_eol[5], argv[4]);
|
||||
if (!ptr_rmodifier)
|
||||
@@ -137,7 +137,7 @@ rmodifier_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
_("%s%s: error creating rmodifier \"%s\""),
|
||||
weechat_prefix ("error"), RMODIFIER_PLUGIN_NAME,
|
||||
argv[2]);
|
||||
return WEECHAT_RC_ERROR;
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
/* create config option */
|
||||
ptr_option = weechat_config_search_option (rmodifier_config_file,
|
||||
@@ -165,7 +165,7 @@ rmodifier_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
_("%sError: missing arguments for \"%s\" "
|
||||
"command"),
|
||||
weechat_prefix ("error"), "rmodifier");
|
||||
return WEECHAT_RC_ERROR;
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
if (weechat_strcasecmp (argv[2], "-all") == 0)
|
||||
{
|
||||
@@ -217,7 +217,7 @@ rmodifier_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
_("%sError: \"-yes\" argument is required for "
|
||||
"restoring default rmodifiers (security reason)"),
|
||||
weechat_prefix ("error"));
|
||||
return WEECHAT_RC_ERROR;
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -211,35 +211,6 @@ rmodifier_modifier_cb (void *data, const char *modifier,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* rmodifier_create_regex: create regex for a rmodifier
|
||||
*/
|
||||
|
||||
void
|
||||
rmodifier_create_regex (struct t_rmodifier *rmodifier)
|
||||
{
|
||||
if (rmodifier->regex)
|
||||
{
|
||||
regfree (rmodifier->regex);
|
||||
free (rmodifier->regex);
|
||||
}
|
||||
|
||||
rmodifier->regex = malloc (sizeof (*rmodifier->regex));
|
||||
if (!rmodifier->regex)
|
||||
return;
|
||||
|
||||
if (regcomp (rmodifier->regex, rmodifier->str_regex,
|
||||
REG_EXTENDED | REG_ICASE) != 0)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: error compiling regular expression \"%s\""),
|
||||
weechat_prefix ("error"), RMODIFIER_PLUGIN_NAME,
|
||||
rmodifier->str_regex);
|
||||
free (rmodifier->regex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* rmodifier_hook_modifiers: hook modifiers for a rmodifier
|
||||
*/
|
||||
@@ -284,11 +255,27 @@ rmodifier_new (const char *name, const char *modifiers, const char *str_regex,
|
||||
const char *groups)
|
||||
{
|
||||
struct t_rmodifier *new_rmodifier, *ptr_rmodifier;
|
||||
regex_t *regex;
|
||||
|
||||
if (!name || !name[0] || !modifiers || !modifiers[0]
|
||||
|| !str_regex || !str_regex[0])
|
||||
return NULL;
|
||||
|
||||
regex = malloc (sizeof (*regex));
|
||||
if (!regex)
|
||||
return NULL;
|
||||
|
||||
if (regcomp (regex, str_regex,
|
||||
REG_EXTENDED | REG_ICASE) != 0)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: error compiling regular expression \"%s\""),
|
||||
weechat_prefix ("error"), RMODIFIER_PLUGIN_NAME,
|
||||
str_regex);
|
||||
free (regex);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ptr_rmodifier = rmodifier_search (name);
|
||||
if (ptr_rmodifier)
|
||||
rmodifier_free (ptr_rmodifier);
|
||||
@@ -300,11 +287,10 @@ rmodifier_new (const char *name, const char *modifiers, const char *str_regex,
|
||||
new_rmodifier->hooks = NULL;
|
||||
new_rmodifier->modifiers = strdup (modifiers);
|
||||
new_rmodifier->str_regex = strdup (str_regex);
|
||||
new_rmodifier->regex = NULL;
|
||||
new_rmodifier->regex = regex;
|
||||
new_rmodifier->groups = strdup ((groups) ? groups : "");
|
||||
|
||||
/* create regex and modifiers */
|
||||
rmodifier_create_regex (new_rmodifier);
|
||||
/* create modifiers */
|
||||
rmodifier_hook_modifiers (new_rmodifier);
|
||||
|
||||
if (rmodifier_list)
|
||||
|
||||
Reference in New Issue
Block a user