]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Merge branch 'bug113-SrvPrefix'
authorAlexander Barton <alex@barton.de>
Tue, 9 Aug 2011 08:16:56 +0000 (10:16 +0200)
committerAlexander Barton <alex@barton.de>
Tue, 9 Aug 2011 08:16:56 +0000 (10:16 +0200)
* bug113-SrvPrefix:
  Slightly change (and document!) IRC_KILL() calling convention
  Spoofed prefixes: close connection on non-server links only

1  2 
src/ngircd/irc-login.c

diff --combined src/ngircd/irc-login.c
index 73716fe261d5d5a4942d2d24d02672fcff2f74cd,c90a7c1c835db59727c9f2081c48d44f9063a147..edaefd61cfc119fbd26de3a26d55eb65bc0146d0
@@@ -653,37 -653,32 +653,37 @@@ IRC_QUIT( CLIENT *Client, REQUEST *Req 
        CLIENT *target;
        char quitmsg[LINE_LEN];
  
 -      assert( Client != NULL );
 -      assert( Req != NULL );
 +      assert(Client != NULL);
 +      assert(Req != NULL);
  
        /* Wrong number of arguments? */
 -      if( Req->argc > 1 )
 -              return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
 +      if (Req->argc > 1)
 +              return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
 +                                        Client_ID(Client), Req->command);
  
        if (Req->argc == 1)
                strlcpy(quitmsg, Req->argv[0], sizeof quitmsg);
  
 -      if ( Client_Type( Client ) == CLIENT_SERVER )
 -      {
 +      if (Client_Type(Client) == CLIENT_SERVER) {
                /* Server */
 -              target = Client_Search( Req->prefix );
 -              if( ! target )
 -              {
 -                      Log( LOG_WARNING, "Got QUIT from %s for unknown client!?", Client_ID( Client ));
 +              target = Client_Search(Req->prefix);
 +              if (!target) {
 +                      Log(LOG_WARNING,
 +                          "Got QUIT from %s for unknown client!?",
 +                          Client_ID(Client));
                        return CONNECTED;
                }
  
 -              Client_Destroy( target, "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true);
 -
 -              return CONNECTED;
 -      }
 -      else
 -      {
 +              if (target != Client) {
 +                      Client_Destroy(target, "Got QUIT command.",
 +                                     Req->argc == 1 ? quitmsg : NULL, true);
 +                      return CONNECTED;
 +              } else {
 +                      Conn_Close(Client_Conn(Client), "Got QUIT command.",
 +                                 Req->argc == 1 ? quitmsg : NULL, true);
 +                      return DISCONNECTED;
 +              }
 +      } else {
                if (Req->argc == 1 && quitmsg[0] != '\"') {
                        /* " " to avoid confusion */
                        strlcpy(quitmsg, "\"", sizeof quitmsg);
                }
  
                /* User, Service, or not yet registered */
 -              Conn_Close( Client_Conn( Client ), "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true);
 +              Conn_Close(Client_Conn(Client), "Got QUIT command.",
 +                         Req->argc == 1 ? quitmsg : NULL, true);
  
                return DISCONNECTED;
        }
@@@ -1102,20 -1096,22 +1102,22 @@@ Hello_User_PostAuth(CLIENT *Client
   * @param Reason      Reason for the KILL.
   */
  static void
- Kill_Nick( char *Nick, char *Reason )
+ Kill_Nick(char *Nick, char *Reason)
  {
        REQUEST r;
  
-       assert( Nick != NULL );
-       assert( Reason != NULL );
+       assert (Nick != NULL);
+       assert (Reason != NULL);
  
-       r.prefix = (char *)Client_ThisServer( );
+       r.prefix = NULL;
        r.argv[0] = Nick;
        r.argv[1] = Reason;
        r.argc = 2;
  
-       Log( LOG_ERR, "User(s) with nick \"%s\" will be disconnected: %s", Nick, Reason );
-       IRC_KILL( Client_ThisServer( ), &r );
+       Log(LOG_ERR, "User(s) with nick \"%s\" will be disconnected: %s",
+           Nick, Reason);
+       IRC_KILL(Client_ThisServer(), &r);
  } /* Kill_Nick */