]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/irc-mode.c
DEFAULT_WHOWAS->DEF_RPL_WHOWAS; MAX_CMODES_ARG->MAX_HNDL_MODES_ARG
[ngircd-alex.git] / src / ngircd / irc-mode.c
index ba44a3ba286f1e592058b2fced15e262183c747d..0c63e7277b2fc3a6a2a172cc96fa07c9b9aa478d 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2011 Alexander Barton (alex@barton.de) and Contributors.
+ * Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -253,7 +253,6 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
                                                        set ? '+' : '-',
                                                        *mode_ptr);
                                x[0] = '\0';
-                               goto client_exit;
                        } else {
                                Log(LOG_DEBUG,
                                    "Handling unknown mode \"%c%c\" from \"%s\" for \"%s\" ...",
@@ -278,11 +277,10 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
                                strlcat(the_modes, x, sizeof(the_modes));
                }
        }
-client_exit:
 
        /* Are there changed modes? */
        if (the_modes[1]) {
-               /* Remoce needless action modifier characters */
+               /* Remove needless action modifier characters */
                len = strlen(the_modes) - 1;
                if (the_modes[len] == '+' || the_modes[len] == '-')
                        the_modes[len] = '\0';
@@ -377,7 +375,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
        char the_modes[COMMAND_LEN], the_args[COMMAND_LEN], x[2],
            argadd[CLIENT_PASS_LEN], *mode_ptr;
        bool connected, set, skiponce, retval, onchannel, modeok, use_servermode;
-       int mode_arg, arg_arg;
+       int mode_arg, arg_arg, mode_arg_count = 0;
        CLIENT *client;
        long l;
        size_t len;
@@ -430,6 +428,8 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
                        mode_ptr++;
                if (!*mode_ptr) {
                        /* Try next argument if there's any */
+                       if (arg_arg < 0)
+                               break;
                        if (arg_arg > mode_arg)
                                mode_arg = arg_arg;
                        else
@@ -491,6 +491,8 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
                                        Client_ID(Origin), Channel_Name(Channel));
                        break;
                case 'k': /* Channel key */
+                       if (mode_arg_count++ >= MAX_HNDL_MODES_ARG)
+                               goto chan_exit;
                        if (!set) {
                                if (modeok)
                                        x[0] = *mode_ptr;
@@ -525,6 +527,8 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
                        }
                        break;
                case 'l': /* Member limit */
+                       if (mode_arg_count++ >= MAX_HNDL_MODES_ARG)
+                               goto chan_exit;
                        if (!set) {
                                if (modeok)
                                        x[0] = *mode_ptr;
@@ -635,6 +639,8 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
                /* --- Channel lists --- */
                case 'I': /* Invite lists */
                case 'b': /* Ban lists */
+                       if (mode_arg_count++ >= MAX_HNDL_MODES_ARG)
+                               goto chan_exit;
                        if (arg_arg > mode_arg) {
                                /* modify list */
                                if (modeok) {
@@ -671,7 +677,6 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
                                        Client_ID(Origin),
                                        set ? '+' : '-', *mode_ptr);
                                x[0] = '\0';
-                               goto chan_exit;
                        } else {
                                Log(LOG_DEBUG,
                                    "Handling unknown mode \"%c%c\" from \"%s\" on %s ...",