Skip to content

Commit

Permalink
kick,remove: don't confuse source and target membership
Browse files Browse the repository at this point in the history
  • Loading branch information
edk0 committed Jul 13, 2021
1 parent b9a7173 commit 883ac66
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions extensions/m_remove.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ DECLARE_MODULE_AV2(remove, NULL, NULL, remove_clist, NULL, remove_hfnlist, remov
static void
m_remove(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct membership *msptr;
struct membership *sourcems, *targetms;
struct Client *who;
struct Channel *chptr;
int chasing = 0;
Expand Down Expand Up @@ -95,16 +95,16 @@ m_remove(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source

if(!IsServer(source_p))
{
msptr = find_channel_membership(chptr, source_p);
sourcems = find_channel_membership(chptr, source_p);

if((msptr == NULL) && MyConnect(source_p))
if((sourcems == NULL) && MyConnect(source_p))
{
sendto_one_numeric(source_p, ERR_NOTONCHANNEL,
form_str(ERR_NOTONCHANNEL), name);
return;
}

if(get_channel_access(source_p, chptr, msptr, MODE_ADD, NULL) < CHFL_CHANOP)
if(get_channel_access(source_p, chptr, sourcems, MODE_ADD, NULL) < CHFL_CHANOP)
{
if(MyConnect(source_p))
{
Expand Down Expand Up @@ -154,9 +154,9 @@ m_remove(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
return;
}

msptr = find_channel_membership(chptr, who);
targetms = find_channel_membership(chptr, who);

if(msptr != NULL)
if(targetms != NULL)
{
if(MyClient(source_p) && IsService(who))
{
Expand All @@ -171,7 +171,7 @@ m_remove(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source

hookdata.client = source_p;
hookdata.chptr = chptr;
hookdata.msptr = msptr;
hookdata.msptr = sourcems;
hookdata.target = who;
hookdata.approved = 1;
hookdata.dir = MODE_ADD; /* ensure modules like override speak up */
Expand Down Expand Up @@ -205,7 +205,7 @@ m_remove(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
":%s KICK %s %s :%s",
use_id(source_p), chptr->chname, use_id(who), comment);

remove_user_from_channel(msptr);
remove_user_from_channel(targetms);
}
else if (MyClient(source_p))
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
Expand Down
16 changes: 8 additions & 8 deletions modules/core/m_kick.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ DECLARE_MODULE_AV2(kick, NULL, NULL, kick_clist, NULL, NULL, NULL, NULL, kick_de
static void
m_kick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct membership *msptr;
struct membership *sourcems, *targetms;
struct Client *who;
struct Channel *chptr;
int chasing = 0;
Expand Down Expand Up @@ -88,16 +88,16 @@ m_kick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p

if(!IsServer(source_p))
{
msptr = find_channel_membership(chptr, source_p);
sourcems = find_channel_membership(chptr, source_p);

if((msptr == NULL) && MyConnect(source_p))
if((sourcems == NULL) && MyConnect(source_p))
{
sendto_one_numeric(source_p, ERR_NOTONCHANNEL,
form_str(ERR_NOTONCHANNEL), name);
return;
}

if(get_channel_access(source_p, chptr, msptr, MODE_ADD, NULL) < CHFL_CHANOP)
if(get_channel_access(source_p, chptr, sourcems, MODE_ADD, NULL) < CHFL_CHANOP)
{
if(MyConnect(source_p))
{
Expand Down Expand Up @@ -127,9 +127,9 @@ m_kick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
return;
}

msptr = find_channel_membership(chptr, who);
targetms = find_channel_membership(chptr, who);

if(msptr != NULL)
if(targetms != NULL)
{
if(MyClient(source_p) && IsService(who))
{
Expand All @@ -144,7 +144,7 @@ m_kick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p

hookdata.client = source_p;
hookdata.chptr = chptr;
hookdata.msptr = msptr;
hookdata.msptr = sourcems;
hookdata.target = who;
hookdata.approved = 1;
hookdata.dir = MODE_ADD; /* ensure modules like override speak up */
Expand Down Expand Up @@ -178,7 +178,7 @@ m_kick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s KICK %s %s :%s",
use_id(source_p), chptr->chname, use_id(who), comment);
remove_user_from_channel(msptr);
remove_user_from_channel(targetms);
}
else if (MyClient(source_p))
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
Expand Down

0 comments on commit 883ac66

Please sign in to comment.