]> arthur.barton.de Git - ngircd.git/blobdiff - src/ngircd/channel.c
KICK: Fix denial of service bug
[ngircd.git] / src / ngircd / channel.c
index 00aafe05a170102a3e22053af73861b50b14e112..45bf615c29d604b453807e2a1e6c2b07c8c3f02c 100644 (file)
@@ -131,11 +131,11 @@ Channel_InitPredefined( void )
 
                new_chan = Channel_Create(conf_chan->name);
                if (!new_chan) {
-                       Log(LOG_ERR, "Can't create pre-defined channel \"%s\"",
+                       Log(LOG_ERR, "Can't create pre-defined channel \"%s\"!",
                                                        conf_chan->name);
                        continue;
                }
-               Log(LOG_INFO, "Created pre-defined channel \"%s\"",
+               Log(LOG_INFO, "Created pre-defined channel \"%s\".",
                                                conf_chan->name);
 
                Channel_ModeAdd(new_chan, 'P');
@@ -326,6 +326,13 @@ Channel_Kick(CLIENT *Peer, CLIENT *Target, CLIENT *Origin, const char *Name,
                }
        }
 
+       /* Check that the client to be kicked is on the specified channel */
+       if (!Channel_IsMemberOf(chan, Target)) {
+               IRC_WriteStrClient(Origin, ERR_USERNOTINCHANNEL_MSG,
+                                  Client_ID(Origin), Client_ID(Target), Name );
+               return;
+       }
+
        if(Client_Type(Peer) == CLIENT_USER) {
                /* Channel mode 'Q' and user mode 'q' on target: nobody but
                 * IRC Operators and servers can kick the target user */
@@ -382,13 +389,6 @@ Channel_Kick(CLIENT *Peer, CLIENT *Target, CLIENT *Origin, const char *Name,
                }
        }
 
-       /* Check that the client to be kicked is on the specified channel */
-       if (!Channel_IsMemberOf(chan, Target)) {
-               IRC_WriteStrClient(Origin, ERR_USERNOTINCHANNEL_MSG,
-                                  Client_ID(Origin), Client_ID(Target), Name );
-               return;
-       }
-
        /* Kick Client from channel */
        Remove_Client( REMOVE_KICK, chan, Target, Origin, Reason, true);
 } /* Channel_Kick */