Matej Cepl
2aa167a4ee
- Add txtJ07eHdR0m6.patch to fix CVE-2021-30184 (reported upstream on https://lists.gnu.org/archive/html/bug-gnu-chess/2021-04/msg00000.html ) OBS-URL: https://build.opensuse.org/request/show/883905 OBS-URL: https://build.opensuse.org/package/show/games/gnuchess?expand=0&rev=33
39 lines
938 B
Diff
39 lines
938 B
Diff
---
|
|
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';
|
|
|