summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2012-10-06 19:05:13 +0200
committerSebastien Helleu <flashcode@flashtux.org>2012-10-06 19:05:13 +0200
commitaa6b88638632343516f175fd572417b7d54d483e (patch)
treeccabc58fe11e5186ba38c6c900e228eb0ca7873d
parent872d1e037248f57e95c5b649139fd9d51f0e5476 (diff)
downloadweechat-aa6b88638632343516f175fd572417b7d54d483e.zip
irc: fix crash when message 352 has too few arguments (bug #37513)
-rw-r--r--ChangeLog1
-rw-r--r--src/plugins/irc/irc-protocol.c34
2 files changed, 23 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 9cba1779d..f9673bd39 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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]);