1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-09 05:23:12 +02:00

Change return value of add_listmode() / add_listmode_ex(). This fixes

a bug when two servers merge, you could see +beI items being set that
already exist, if the timestamp or setter differed between servers.
Now they are updated but no +beI is shown.
https://bugs.unrealircd.org/view.php?id=5681
This commit is contained in:
Bram Matthys
2023-05-08 18:49:25 +02:00
parent 2c73a37ac7
commit 5b071d7bfd
4 changed files with 14 additions and 9 deletions
+6 -1
View File
@@ -242,12 +242,16 @@ int identical_ban(const char *one, const char *two)
/** Add a listmode (+beI) with the specified banid to
* the specified channel. (Extended version with
* set by nick and set on timestamp)
* @retval 1 Added
* @retval 0 Updated
* @retval -1 Ban list full
*/
int add_listmode_ex(Ban **list, Client *client, Channel *channel, const char *banid, const char *setby, time_t seton)
{
Ban *ban;
int cnt = 0, len;
int do_not_add = 0;
char isnew = 0;
//if (MyUser(client))
// collapse(banid);
@@ -294,6 +298,7 @@ int add_listmode_ex(Ban **list, Client *client, Channel *channel, const char *ba
ban = make_ban();
ban->next = *list;
*list = ban;
isnew = 1;
}
if ((ban->when > 0) && (seton >= ban->when))
@@ -308,7 +313,7 @@ int add_listmode_ex(Ban **list, Client *client, Channel *channel, const char *ba
safe_strdup(ban->banstr, banid); /* cAsE may differ, use oldest version of it */
safe_strdup(ban->who, setby);
ban->when = seton;
return 0;
return isnew ? 1 : 0;
}
/** Add a listmode (+beI) with the specified banid to
+3 -3
View File
@@ -1407,7 +1407,7 @@ int floodprot_can_send_to_channel(Client *client, Channel *channel, Membership *
} else {
snprintf(mask, sizeof(mask), "*!*@%s", GetHost(client));
}
if (add_listmode(&channel->banlist, &me, channel, mask) == 0)
if (add_listmode(&channel->banlist, &me, channel, mask) == 1)
{
mtags = NULL;
new_message(&me, NULL, &mtags);
@@ -1415,7 +1415,7 @@ int floodprot_can_send_to_channel(Client *client, Channel *channel, Membership *
sendto_channel(channel, &me, NULL, 0, 0, SEND_LOCAL, mtags,
":%s MODE %s +b %s", me.name, channel->name, mask);
free_message_tags(mtags);
} /* else.. ban list is full */
} /* else.. ban list is full or already exists */
}
mtags = NULL;
kick_user(NULL, channel, &me, client, errbuf);
@@ -1777,7 +1777,7 @@ int do_floodprot_action_alternative(Channel *channel, int what, FloodType *flood
floodtype->alternative_ban_action);
/* Add the ban internally */
if (add_listmode(&channel->banlist, &me, channel, ban) == -1)
if (add_listmode(&channel->banlist, &me, channel, ban) != 1)
return 0; /* ban list full (or ban already exists) */
/* First the notice to the chanops */
+2 -2
View File
@@ -593,10 +593,10 @@ const char *mode_ban_handler(Client *client, Channel *channel, const char *param
}
}
if ( (what == MODE_ADD && add_listmode(banlist, client, channel, tmpstr)) ||
if ( (what == MODE_ADD && (add_listmode(banlist, client, channel, tmpstr) != 1)) ||
(what == MODE_DEL && del_listmode(banlist, channel, tmpstr)))
{
return NULL; /* already exists */
return NULL; /* ban to be added already exists, or ban to be deleted does not exist */
}
return tmpstr;
+3 -3
View File
@@ -531,21 +531,21 @@ CMD_FUNC(cmd_sjoin)
/* Adding of list modes */
if (*item_modes == 'b')
{
if (add_listmode_ex(&channel->banlist, client, channel, item, setby, setat) != -1)
if (add_listmode_ex(&channel->banlist, client, channel, item, setby, setat) == 1)
{
Addit('b', item);
}
}
if (*item_modes == 'e')
{
if (add_listmode_ex(&channel->exlist, client, channel, item, setby, setat) != -1)
if (add_listmode_ex(&channel->exlist, client, channel, item, setby, setat) == 1)
{
Addit('e', item);
}
}
if (*item_modes == 'I')
{
if (add_listmode_ex(&channel->invexlist, client, channel, item, setby, setat) != -1)
if (add_listmode_ex(&channel->invexlist, client, channel, item, setby, setat) == 1)
{
Addit('I', item);
}