gnuchess/txtJ07eHdR0m6.patch

39 lines
938 B
Diff
Raw Normal View History

---
src/frontend/cmd.cc | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
--- a/src/frontend/cmd.cc
+++ b/src/frontend/cmd.cc
@@ -480,8 +480,13 @@ void cmd_pgnload(void)
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 @@ void cmd_pgnreplay(void)
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';