about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2015-12-13 21:56:07 +0100
committerAlexander Barton <alex@barton.de>2015-12-13 21:56:07 +0100
commit1e386fb7acdf6754a9ee4e6ddc8fa7180f6e5c1e (patch)
treec6379efcf7610ab01b053af0d7bd9da2598ed7b3 /src
parent52ccba5d1e8cd2e648cf3c14598332bde6b9910d (diff)
downloadngircd-1e386fb7acdf6754a9ee4e6ddc8fa7180f6e5c1e.tar.gz
ngircd-1e386fb7acdf6754a9ee4e6ddc8fa7180f6e5c1e.zip
Make NJOIN handler more fault-tolerant
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.
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/irc-server.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/ngircd/irc-server.c b/src/ngircd/irc-server.c
index 6ca3c332..86d97a2f 100644
--- a/src/ngircd/irc-server.c
+++ b/src/ngircd/irc-server.c
@@ -31,6 +31,7 @@
 #include "parse.h"
 #include "numeric.h"
 #include "ngircd.h"
+#include "irc.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;
 		}
 
-		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);