]> git.sesse.net Git - stockfish/commit
Fix 'position ..... moves ' parsing bug
authorMarco Costalba <mcostalba@gmail.com>
Thu, 7 Jan 2010 10:59:32 +0000 (11:59 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 7 Jan 2010 10:59:32 +0000 (11:59 +0100)
commit7c0679ad61d7787dc3a3326551acbdf6658db0b0
treef6c0cf016453d00067206e0025ceb856e1f41de4
parentcc974fa7a4ffc5511ca6c4bc9ae1ef40c2827772
Fix 'position ..... moves ' parsing bug

If after 'moves' there is a space then we crash.

The problem is that operator>>() trims whitespaces so that
after 'moves' has been extract we are still not at eof()
but remaining string contains only spaces. So that the next
extarction operation uip >> token ends up with unchanged token
value that remains 'moves', this garbage value is then feeded
to RootPosition.do_move() through move_from_string() that does
not detect the invalid move value leading to a crash.

This bug is triggered by Shredder 12 interface under Mac that
puts a space after 'moves' without any actual move list.

Bug fixed by Justin Blanchard

After reviewing UCI parsing code I spotted other possible weak
points due to the fact that we don't test if the last extract
operation has been succesful. So I have extended Justing patch
to fix the remaining possible holes in uci.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/uci.cpp