summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2018-03-24 17:10:08 +0100
committerSébastien Helleu <flashcode@flashtux.org>2018-03-24 17:10:08 +0100
commitde825c91520b44e4e2efe6a8f66738e5a5aaec2a (patch)
treea149d1876758937436c755bcd7a39bb5e7ff5d69 /src/plugins
parent50d39969cb1fb6bd46213b185d5ae764cfd60d3a (diff)
downloadweechat-de825c91520b44e4e2efe6a8f66738e5a5aaec2a.zip
irc: check that the modelist item number is valid before using it
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/irc/irc-info.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/plugins/irc/irc-info.c b/src/plugins/irc/irc-info.c
index 9f7b6eb42..1eaab8711 100644
--- a/src/plugins/irc/irc-info.c
+++ b/src/plugins/irc/irc-info.c
@@ -683,8 +683,9 @@ irc_info_infolist_irc_modelist_item_cb (const void *pointer, void *data,
struct t_irc_channel *ptr_channel;
struct t_irc_modelist *ptr_modelist;
struct t_irc_modelist_item *ptr_item;
- char **argv;
+ char **argv, *error;
int argc;
+ long number;
/* make C compiler happy */
(void) pointer;
@@ -722,8 +723,14 @@ irc_info_infolist_irc_modelist_item_cb (const void *pointer, void *data,
}
if (!obj_pointer && (argc >= 4))
{
- obj_pointer = irc_modelist_item_number (ptr_modelist, atoi(argv[3]));
-
+ error = NULL;
+ number = strtol (argv[3], &error, 10);
+ if (!error || error[0] || (number < 0))
+ {
+ weechat_string_free_split (argv);
+ return NULL;
+ }
+ obj_pointer = irc_modelist_item_number (ptr_modelist, (int)number);
if (!obj_pointer)
{
weechat_string_free_split (argv);