X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=b9e1df5d50fdd625774cf266aee4b736100e3d93;hb=546f375a5c8c0fa19d383c3d9822f795c6795e9d;hp=1a03a3f3ec5e77297e0e5709e4cc1408f2e69bf8;hpb=b8ccc2d03263c833777a7c055a372501b40bc7ce;p=xboard.git diff --git a/backend.c b/backend.c index 1a03a3f..b9e1df5 100644 --- a/backend.c +++ b/backend.c @@ -116,7 +116,7 @@ typedef struct { /* Search stats from chessprogram */ typedef struct { - char movelist[MSG_SIZ]; /* Last PV we were sent */ + char movelist[2*MSG_SIZ]; /* Last PV we were sent */ int depth; /* Current search depth */ int nr_moves; /* Total nr of root moves */ int moves_left; /* Moves remaining to be searched */ @@ -3907,7 +3907,7 @@ HandleMachineMove(message, cps) * Look for communication commands */ if (!strncmp(message, "telluser ", 9)) { - DisplayInformation(message + 9); + DisplayNote(message + 9); return; } if (!strncmp(message, "tellusererror ", 14)) { @@ -3921,7 +3921,7 @@ HandleMachineMove(message, cps) SendToICS(buf1); } } else { - DisplayInformation(message + 13); + DisplayNote(message + 13); } return; } @@ -3941,7 +3941,7 @@ HandleMachineMove(message, cps) SendToICS(buf1); } } else { - DisplayInformation(message + 8); + DisplayNote(message + 8); } return; } @@ -4349,9 +4349,24 @@ HandleMachineMove(message, cps) programStats.nodes = nodes; programStats.time = time; programStats.score = curscore; - strcpy(programStats.movelist, buf1); programStats.got_only_move = 0; + /* Buffer overflow protection */ + if (buf1[0] != NULLCHAR) { + if (strlen(buf1) >= sizeof(programStats.movelist) + && appData.debugMode) { + fprintf(debugFP, + "PV is too long; using the first %d bytes.\n", + sizeof(programStats.movelist) - 1); + } + strncpy(programStats.movelist, buf1, + sizeof(programStats.movelist)); + programStats.movelist[sizeof(programStats.movelist) - 1] + = NULLCHAR; + } else { + sprintf(programStats.movelist, " no PV\n"); + } + if (programStats.seen_stat) { programStats.ok_to_send = 1; } @@ -6792,7 +6807,7 @@ ReloadCmailMsgEvent(unregister) /* Load first game in the file or popup game menu */ LoadGameFromFile(inFilename, 0, appData.cmailGameName, TRUE); -#endif // !WIN32 +#endif /* !WIN32 */ return; } @@ -6972,7 +6987,7 @@ MailMoveEvent() } return; -#endif // !WIN32 +#endif /* !WIN32 */ } char * @@ -7050,7 +7065,7 @@ CmailMsg() } } return cmailMsg; -#endif // WIN32 +#endif /* WIN32 */ } void