From 5a4a71731c10465cb8961b96e709eae89f5ef66d Mon Sep 17 00:00:00 2001 From: panstromek Date: Thu, 6 May 2021 09:35:21 +0200 Subject: [PATCH] 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. --- game.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/game.c b/game.c index 51674d2..a1771b3 100644 --- a/game.c +++ b/game.c @@ -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;