Fix issue with duplicate entries in the +b/+e/+I list of +P channels.

This was caused by the transition from letter extbans (eg ~a) to
named extbans (eg ~account) and a combination of the bug fix in 6.0.2
(60a70acd86) and the 'channeldb' module
not checking for duplicates while reading the database.

Reported by PeGaSuS in https://bugs.unrealircd.org/view.php?id=6091
This commit is contained in:
Bram Matthys 2022-04-18 08:39:34 +02:00
parent a9de2696d4
commit 3451919b06
No known key found for this signature in database
GPG key ID: BF8116B163EAAE98

View file

@ -359,6 +359,14 @@ int write_channel_entry(UnrealDB *db, const char *tmpfname, Channel *channel)
return 1;
}
int ban_exists(Ban *lst, Ban *e)
{
for (; lst; lst = lst->next)
if (!mycmp(lst->banstr, e->banstr))
return 1;
return 0;
}
#define R_SAFE(x) \
do { \
if (!(x)) { \
@ -401,10 +409,18 @@ int read_listmode(UnrealDB *db, Ban **lst)
}
safe_strdup(e->banstr, str);
/* Add to list */
e->when = when;
e->next = *lst;
*lst = e;
if (ban_exists(*lst, e))
{
/* Free again - duplicate item */
safe_free(e->banstr);
safe_free(e->who);
safe_free(e);
} else {
/* Add to list */
e->when = when;
e->next = *lst;
*lst = e;
}
}
return 1;