summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mode.cpp57
-rw-r--r--src/modules/m_spanningtree.cpp22
2 files changed, 48 insertions, 31 deletions
diff --git a/src/mode.cpp b/src/mode.cpp
index fc2e04b1e..d07675e5f 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -585,6 +585,8 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
while (modelist[len-1] == ' ')
modelist[--len] = '\0';
+ bool next_cant_be_modifier = false;
+
for (char* modechar = modelist; *modechar; ptr++, modechar++)
{
r = NULL;
@@ -595,40 +597,50 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
if (pc > MAXMODES-1)
break;
+ if ((*modechar != '+') && (*modechar != '-'))
+ next_cant_be_modifier = false;
+
{
switch (*modechar)
{
case '-':
- if (mdir != 0)
+ if (!next_cant_be_modifier)
{
- int t = strlen(outlist)-1;
- if ((outlist[t] == '+') || (outlist[t] == '-'))
- {
- outlist[t] = '-';
- }
- else
+ if (mdir != 0)
{
- strcat(outlist,"-");
+ int t = strlen(outlist)-1;
+ if ((outlist[t] == '+') || (outlist[t] == '-'))
+ {
+ outlist[t] = '-';
+ }
+ else
+ {
+ strcat(outlist,"-");
+ }
}
+ mdir = 0;
+ next_cant_be_modifier = true;
}
- mdir = 0;
-
break;
case '+':
- if (mdir != 1)
+ if (!next_cant_be_modifier)
{
- int t = strlen(outlist)-1;
- if ((outlist[t] == '+') || (outlist[t] == '-'))
+ if (mdir != 1)
{
- outlist[t] = '+';
- }
- else
- {
- strcat(outlist,"+");
+ int t = strlen(outlist)-1;
+ if ((outlist[t] == '+') || (outlist[t] == '-'))
+ {
+ outlist[t] = '+';
+ }
+ else
+ {
+ strcat(outlist,"+");
+ }
}
+ mdir = 1;
+ next_cant_be_modifier = true;
}
- mdir = 1;
break;
case 'o':
@@ -1113,13 +1125,14 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
}
/* this ensures only the *valid* modes are sent out onto the network */
- int xt = strlen(outlist)-1;
+ /*int xt = strlen(outlist)-1;
while ((outlist[xt] == '-') || (outlist[xt] == '+'))
{
outlist[xt] = '\0';
xt = strlen(outlist)-1;
- }
- if (outlist[0])
+ }*/
+ /* The mode change must be at least two characters long (+ or - and at least one mode) */
+ if (((*outlist == '+') || (*outlist == '-')) && *(outlist+1))
{
strlcpy(outstr,outlist,MAXBUF);
for (ptr = 0; ptr < pc; ptr++)
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index 7086ce1da..ccc5cd6dc 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -864,13 +864,14 @@ class TreeSocket : public InspSocket
}
/* FMODE command */
- bool ForceMode(std::string source, std::deque<std::string> params)
+ bool ForceMode(std::string source, std::deque<std::string> &params)
{
- userrec* who = new userrec;
- who->fd = FD_MAGIC_NUMBER;
if (params.size() < 2)
return true;
- char* modelist[255];
+ userrec* who = new userrec();
+ who->fd = FD_MAGIC_NUMBER;
+ char* modelist[64];
+ memset(&modelist,0,sizeof(modelist));
for (unsigned int q = 0; q < params.size(); q++)
{
modelist[q] = (char*)params[q].c_str();
@@ -882,7 +883,7 @@ class TreeSocket : public InspSocket
}
/* FTOPIC command */
- bool ForceTopic(std::string source, std::deque<std::string> params)
+ bool ForceTopic(std::string source, std::deque<std::string> &params)
{
if (params.size() != 4)
return true;
@@ -927,7 +928,7 @@ class TreeSocket : public InspSocket
}
/* FJOIN, similar to unreal SJOIN */
- bool ForceJoin(std::string source, std::deque<std::string> params)
+ bool ForceJoin(std::string source, std::deque<std::string> &params)
{
if (params.size() < 3)
return true;
@@ -935,6 +936,7 @@ class TreeSocket : public InspSocket
char first[MAXBUF];
char modestring[MAXBUF];
char* mode_users[127];
+ memset(&mode_users,0,sizeof(mode_users));
mode_users[0] = first;
mode_users[1] = modestring;
strcpy(mode_users[1],"+");
@@ -1057,7 +1059,7 @@ class TreeSocket : public InspSocket
}
/* NICK command */
- bool IntroduceClient(std::string source, std::deque<std::string> params)
+ bool IntroduceClient(std::string source, std::deque<std::string> &params)
{
if (params.size() < 8)
return true;
@@ -1203,7 +1205,8 @@ class TreeSocket : public InspSocket
void SendXLines(TreeServer* Current)
{
char data[MAXBUF];
- const char* sn = Srv->GetServerName().c_str();
+ std::string n = Srv->GetServerName();
+ const char* sn = n.c_str();
int iterations = 0;
/* Yes, these arent too nice looking, but they get the job done */
for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++, iterations++)
@@ -1286,7 +1289,8 @@ class TreeSocket : public InspSocket
char data[MAXBUF];
std::deque<std::string> list;
int iterations = 0;
- const char* sn = Srv->GetServerName().c_str();
+ std::string n = Srv->GetServerName();
+ const char* sn = n.c_str();
for (chan_hash::iterator c = chanlist.begin(); c != chanlist.end(); c++, iterations++)
{
SendFJoins(Current, c->second);