oy/teeworlds — pull request #906 by eeeee (2011-12-27 01:57:15+00:00)
Title: Bans fix

Introduction of lifebans has numerous problems, due to expiration time set to unusual value and not handling that in all places in code.

Example:

in rcon first type:

ban 1.2.3.4 -1
ban 1.2.3.5 1

then you'll get

bans
#0 1.2.3.4 for life
#1 1.2.3.5 for 0 minutes and 59 seconds

and after one minute

bans
#0 1.2.3.4 for life
#1 1.2.3.5 for 71582788 minutes and 15 seconds

Problem is that ban handling code assumes that ban list is sorted by expiration ascending. This way it can always check only the first ban in the list for expiration.
Obviously, this approach doesn't work when first ban in the list is a lifeban.
Another problem is the ability to alter expiration time of existing bans without moving them anywhere in the list, which breaks the assumption.
Finally, providing too large values for expiration time can cause overflow and undefined behavior.

Proposed patch addresses all those problems.