]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Make NJOIN handler more fault-tolerant
authorAlexander Barton <alex@barton.de>
Sun, 13 Dec 2015 20:56:07 +0000 (21:56 +0100)
committerAlexander Barton <alex@barton.de>
Sun, 13 Dec 2015 20:56:07 +0000 (21:56 +0100)
Don't crash the daemon when the NJOIN handler can't join the new client
to a channel (when the Channel_Join() function failed) but try to KILL this
client -- which is the only possible reaction besides crashing: otherwise
the network would get out of sync.

src/ngircd/irc-server.c

index 6ca3c33288ebfd595084cf77a28863974957abbc..86d97a2f74ca8abdd52945f34fb7c2b46804a58b 100644 (file)
@@ -31,6 +31,7 @@
 #include "parse.h"
 #include "numeric.h"
 #include "ngircd.h"
 #include "parse.h"
 #include "numeric.h"
 #include "ngircd.h"
+#include "irc.h"
 #include "irc-info.h"
 #include "irc-write.h"
 #include "op.h"
 #include "irc-info.h"
 #include "irc-write.h"
 #include "op.h"
@@ -282,7 +283,16 @@ IRC_NJOIN( CLIENT *Client, REQUEST *Req )
                        goto skip_njoin;
                }
 
                        goto skip_njoin;
                }
 
-               Channel_Join(c, channame);
+               if (Channel_Join(c, channame)) {
+                       /* Failed to join channel. Ooops!? */
+                       Log(LOG_ALERT,
+                           "Failed to join client \"%s\" to channel \"%s\" (NJOIN): killing it!",
+                           ptr, channame);
+                       IRC_KillClient(NULL, NULL, ptr, "Internal NJOIN error!");
+                       Log(LOG_DEBUG, "... done.");
+                       goto skip_njoin;
+               }
+
                chan = Channel_Search(channame);
                assert(chan != NULL);
 
                chan = Channel_Search(channame);
                assert(chan != NULL);