diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2012-10-06 19:05:13 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2012-10-06 19:05:13 +0200 |
commit | aa6b88638632343516f175fd572417b7d54d483e (patch) | |
tree | ccabc58fe11e5186ba38c6c900e228eb0ca7873d | |
parent | 872d1e037248f57e95c5b649139fd9d51f0e5476 (diff) | |
download | weechat-aa6b88638632343516f175fd572417b7d54d483e.zip |
irc: fix crash when message 352 has too few arguments (bug #37513)
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 34 |
2 files changed, 23 insertions, 12 deletions
@@ -8,6 +8,7 @@ Version 0.4.0 (under dev!) -------------------------- * aspell: add bar item "aspell_dict" (dictionary used on current buffer) +* irc: fix crash when message 352 has too few arguments (bug #37513) * irc: remove unneeded server disconnect when server buffer is closed and server is already disconnected * relay: add missing "ssl." in output of /relay listrelay diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index a380bed6c..aeb82785a 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -3636,21 +3636,31 @@ IRC_PROTOCOL_CALLBACK(352) * :server 352 mynick #channel user host server nick (*) (H/G) :0 flashcode */ - arg_start = (strcmp (argv[8], "*") == 0) ? 9 : 8; + IRC_PROTOCOL_MIN_ARGS(5); - IRC_PROTOCOL_MIN_ARGS(arg_start + 1); + /* silently ignore malformed 352 message (missing infos) */ + if (argc < 8) + return WEECHAT_RC_OK; - if (argv[arg_start][0] == ':') - { - pos_attr = NULL; - pos_hopcount = (argc > arg_start) ? argv[arg_start] + 1 : NULL; - pos_realname = (argc > arg_start + 1) ? argv_eol[arg_start + 1] : NULL; - } - else + pos_attr = NULL; + pos_hopcount = NULL; + pos_realname = NULL; + + if (argc > 8) { - pos_attr = argv[arg_start]; - pos_hopcount = (argc > arg_start + 1) ? argv[arg_start + 1] + 1 : NULL; - pos_realname = (argc > arg_start + 2) ? argv_eol[arg_start + 2] : NULL; + arg_start = (strcmp (argv[8], "*") == 0) ? 9 : 8; + if (argv[arg_start][0] == ':') + { + pos_attr = NULL; + pos_hopcount = (argc > arg_start) ? argv[arg_start] + 1 : NULL; + pos_realname = (argc > arg_start + 1) ? argv_eol[arg_start + 1] : NULL; + } + else + { + pos_attr = argv[arg_start]; + pos_hopcount = (argc > arg_start + 1) ? argv[arg_start + 1] + 1 : NULL; + pos_realname = (argc > arg_start + 2) ? argv_eol[arg_start + 2] : NULL; + } } ptr_channel = irc_channel_search (server, argv[3]); |