--- /tmp/cmd.cc 2021-04-04 23:20:06.720388661 -0400 +++ cmd.cc 2021-04-04 23:14:35.095359251 -0400 @@ -480,8 +480,13 @@ strcpy( data, "setboard " ); int i=0; while ( epdline[i] != '\n' ) { - data[i+9] = epdline[i]; - ++i; + if ((i + 9) < MAXSTR - 1) { + data[i+9] = epdline[i]; + ++i; + } else { + printf(_("Error reading contents of file '%s'.\n"), token[1]); + break; + } } data[i+9] = '\0'; SetDataToEngine( data ); @@ -504,8 +509,13 @@ strcpy( data, "setboard " ); int i=0; while ( epdline[i] != '\n' ) { - data[i+9] = epdline[i]; - ++i; + if ((i + 9) < MAXSTR - 1) { + data[i+9] = epdline[i]; + ++i; + } else { + printf(_("Error reading contents of file '%s'.\n"), token[1]); + break; + } } data[i+9] = '\0';