Skip to content

Commit ff96dc6

Browse files
committed
fix buffer overflow when reading board file
1 parent 941f056 commit ff96dc6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

game.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ global_terminate( void ) {
199199

200200
static void
201201
setup_game( const char *file_name, int *side_to_move ) {
202-
char buffer[65];
202+
int BUFFER_SIZE = 70;
203+
char buffer[BUFFER_SIZE];
203204
int i, j;
204205
int pos, token;
205206
FILE *stream;
@@ -222,7 +223,7 @@ setup_game( const char *file_name, int *side_to_move ) {
222223
stream = fopen( file_name, "r" );
223224
if ( stream == NULL )
224225
fatal_error( "%s '%s'\n", GAME_LOAD_ERROR, file_name );
225-
fgets( buffer, 70, stream );
226+
fgets(buffer, BUFFER_SIZE, stream );
226227
token = 0;
227228
for ( i = 1; i <= 8; i++ )
228229
for ( j = 1; j <= 8; j++ ) {

0 commit comments

Comments
 (0)