lunixbochs / uberserver

matchmaking/chat lobby server for the spring rts project
MIT License
8 stars 4 forks source link

int() dont check range #13

Closed cleanrock closed 11 years ago

cleanrock commented 11 years ago

I noticed this warning when running flobby : W-20:14:46-Model.cpp:404] failed to process server msg:'BATTLEOPENED 12422 0 0 [o]PepeAmpere[CZ] #.#.#.# 8452 32 0 0 3803459876 RoughShoresV6 gay games NOTA 1.xxx' (bad lexical cast: source type value could not be interpreted as target)

PepeAmpere said they were testing NotaLobby which obviously send unsigned int for map checksum (3803459876) in OPENBATTLE(EX) so its a bug in NotaLobby (i will inform them) but also in uberserver.

int() does not check the range, here is a python function which will check that its a 32-bit signed int:

def int32(x):
    val = int(x)
    if val >  2147483647 : raise OverflowError
    if val < -2147483648 : raise OverflowError
    return val

So just add this function and use it where you expect 32-bit signed integers, e.g. in_OPENBATTLE and in_OPENBATTLEEX.

PS. I was planning to make a pull request but it seems i can only have one fork on github.