Skip to content

Commit

Permalink
fix buffer overflow when reading board file
Browse files Browse the repository at this point in the history
  • Loading branch information
panstromek committed Feb 20, 2022
1 parent 881be18 commit ecf160e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions game.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ global_terminate( void ) {

static void
setup_game( const char *file_name, int *side_to_move ) {
char buffer[65];
int BUFFER_SIZE = 70;
char buffer[BUFFER_SIZE];
int i, j;
int pos, token;
FILE *stream;
Expand All @@ -222,7 +223,7 @@ setup_game( const char *file_name, int *side_to_move ) {
stream = fopen( file_name, "r" );
if ( stream == NULL )
fatal_error( "%s '%s'\n", GAME_LOAD_ERROR, file_name );
fgets( buffer, 70, stream );
fgets(buffer, BUFFER_SIZE, stream );
token = 0;
for ( i = 1; i <= 8; i++ )
for ( j = 1; j <= 8; j++ ) {
Expand Down

0 comments on commit ecf160e

Please sign in to comment.