]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/mode.cpp
XLine fixes and fix to +l with large limits
[user/henk/code/inspircd.git] / src / mode.cpp
index 3458cab2841ddf5cf42e8dd3d8154ade8099ccbd..f23546d75ef9d2a1da081ba431905c3105bf09c8 100644 (file)
@@ -32,6 +32,8 @@
 #include "dynamic.h"
 #include "wildcard.h"
 #include "message.h"
+#include "commands.h"
+#include "xline.h"
 
 using namespace std;
 
@@ -64,7 +66,7 @@ int give_ops(userrec *user,char *dest,chanrec *chan,int status)
                log(DEFAULT,"*** BUG *** give_ops was given an invalid parameter");
                return 0;
        }
-       if (status < STATUS_OP)
+       if ((status < STATUS_OP) && (!is_uline(user->server)))
        {
                log(DEBUG,"%s cant give ops to %s because they nave status %d and needs %d",user->nick,dest,status,STATUS_OP);
                WriteServ(user->fd,"482 %s %s :You're not a channel operator",user->nick, chan->name);
@@ -119,7 +121,7 @@ int give_hops(userrec *user,char *dest,chanrec *chan,int status)
                log(DEFAULT,"*** BUG *** give_hops was given an invalid parameter");
                return 0;
        }
-       if (status != STATUS_OP)
+       if ((status < STATUS_OP) && (!is_uline(user->server)))
        {
                WriteServ(user->fd,"482 %s %s :You're not a channel operator",user->nick, chan->name);
                return 0;
@@ -169,7 +171,7 @@ int give_voice(userrec *user,char *dest,chanrec *chan,int status)
                log(DEFAULT,"*** BUG *** give_voice was given an invalid parameter");
                return 0;
        }
-       if (status < STATUS_HOP)
+       if ((status < STATUS_HOP) && (!is_uline(user->server)))
        {
                WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, chan->name);
                return 0;
@@ -219,7 +221,7 @@ int take_ops(userrec *user,char *dest,chanrec *chan,int status)
                log(DEFAULT,"*** BUG *** take_ops was given an invalid parameter");
                return 0;
        }
-       if (status < STATUS_OP)
+       if ((status < STATUS_OP) && (!is_uline(user->server)))
        {
                log(DEBUG,"%s cant give ops to %s because they have status %d and needs %d",user->nick,dest,status,STATUS_OP);
                WriteServ(user->fd,"482 %s %s :You're not a channel operator",user->nick, chan->name);
@@ -273,7 +275,7 @@ int take_hops(userrec *user,char *dest,chanrec *chan,int status)
                log(DEFAULT,"*** BUG *** take_hops was given an invalid parameter");
                return 0;
        }
-       if (status != STATUS_OP)
+       if ((status < STATUS_OP) && (!is_uline(user->server)))
        {
                WriteServ(user->fd,"482 %s %s :You're not a channel operator",user->nick, chan->name);
                return 0;
@@ -323,7 +325,7 @@ int take_voice(userrec *user,char *dest,chanrec *chan,int status)
                log(DEFAULT,"*** BUG *** take_voice was given an invalid parameter");
                return 0;
        }
-       if (status < STATUS_HOP)
+       if ((status < STATUS_HOP) && (!is_uline(user->server)))
        {
                WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, chan->name);
                return 0;
@@ -654,6 +656,11 @@ void process_modes(char **parameters,userrec* user,chanrec *chan,int status, int
                                                        break;
                                                
                                                chan->limit = atoi(parameters[param]);
+                                               
+                                               // reported by mech: large values cause underflow
+                                               if (chan->limit < 0)
+                                                       chan->limit = MAXINT;
+                                                       
                                                if (chan->limit)
                                                {
                                                        strcat(outlist,"l");
@@ -1723,12 +1730,15 @@ void merge_mode2(char **parameters, int pcnt, userrec* user)
        Ptr = FindChan(parameters[0]);
        if (Ptr)
        {
-               if ((cstatus(user,Ptr) < STATUS_HOP) && (Ptr))
+               log(DEBUG,"merge_mode2: found channel %s",Ptr->name);
+               if (Ptr)
                {
-                       return;
+                       if ((cstatus(user,Ptr) < STATUS_HOP) && (!is_uline(user->server)))
+                       {
+                               return;
+                       }
+                       process_modes(parameters,user,Ptr,cstatus(user,Ptr),pcnt,false,false,true);
                }
-
-               process_modes(parameters,user,Ptr,cstatus(user,Ptr),pcnt,false,false,true);
        }
 }