Skip to content

Commit caa3cf2

Browse files
committed
fix some index out of bounds by requiring initial disks in file board 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.
1 parent 8c8d7b3 commit caa3cf2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

game.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ setup_game( const char *file_name, int *side_to_move ) {
260260
else
261261
fatal_error( "%s '%c' %s\n", BAD_CHARACTER_ERROR, buffer[0],
262262
GAME_FILE_TEXT);
263+
if (board[45] == EMPTY || board[54] == EMPTY || board[44] == EMPTY || board[55] == EMPTY) {
264+
// various pieces of the program are not ready for this, even though we have end solve routines for it
265+
fatal_error( "Initial squares (d4, e4, d5, e5) from the board file should not be empty.\n");
266+
}
263267
}
264268
disks_played = disc_count( BLACKSQ ) + disc_count( WHITESQ ) - 4;
265269

0 commit comments

Comments
 (0)