(svn r24580) -Fix [FS#5308]: Do not add duplicates to the ban list. (alechz)

This commit is contained in:
frosch 2012-10-09 20:36:31 +00:00
parent a9af5f3c76
commit de770d7563
1 changed files with 10 additions and 1 deletions

View File

@ -2052,7 +2052,16 @@ uint NetworkServerKickOrBanIP(ClientID client_id, bool ban)
uint NetworkServerKickOrBanIP(const char *ip, bool ban)
{
/* Add address to ban-list */
if (ban) *_network_ban_list.Append() = strdup(ip);
if (ban) {
bool contains = false;
for (char **iter = _network_ban_list.Begin(); iter != _network_ban_list.End(); iter++) {
if (strcmp(*iter, ip) == 0) {
contains = true;
break;
}
}
if (!contains) *_network_ban_list.Append() = strdup(ip);
}
uint n = 0;