Skip to content

Commit

Permalink
fix some index out of bounds by requiring initial disks in file board…
Browse files Browse the repository at this point in the history
… source

This causes some UB in the end solver and the game is not ready for this case for multiple reasons - lot of routines assume only 60 moves or that initial disks are not empty.
  • Loading branch information
panstromek committed Feb 20, 2022
1 parent c779fba commit 5a4a717
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions game.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ setup_game( const char *file_name, int *side_to_move ) {
else
fatal_error( "%s '%c' %s\n", BAD_CHARACTER_ERROR, buffer[0],
GAME_FILE_TEXT);
if (board[45] == EMPTY || board[54] == EMPTY || board[44] == EMPTY || board[55] == EMPTY) {
// various pieces of the program are not ready for this, even though we have end solve routines for it
fatal_error( "Initial squares (d4, e4, d5, e5) from the board file should not be empty.\n");
}
}
disks_played = disc_count( BLACKSQ ) + disc_count( WHITESQ ) - 4;

Expand Down

0 comments on commit 5a4a717

Please sign in to comment.