X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=f28d863fe4888d1e8d5f56b4440fb46933b85d27;hb=bc9927eb7497911debdd6bc80cab75dba837f7bc;hp=690662daa655e03a1f09b2cbf3eaa7375e98f87c;hpb=7eac61e425829b5d51957fcd0a343ca923261868;p=xboard.git diff --git a/backend.c b/backend.c index 690662d..f28d863 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 */ @@ -1455,6 +1455,16 @@ read_from_ics(isr, closure, data, count, error) int tkind; char *p; +#ifdef WIN32 + if (appData.debugMode) { + if (!error) { + fprintf(debugFP, " 0) { /* If last read ended with a partial line that we couldn't parse, prepend it to the new read and try again. */ @@ -3907,7 +3917,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 +3931,7 @@ HandleMachineMove(message, cps) SendToICS(buf1); } } else { - DisplayInformation(message + 13); + DisplayNote(message + 13); } return; } @@ -3941,7 +3951,7 @@ HandleMachineMove(message, cps) SendToICS(buf1); } } else { - DisplayInformation(message + 8); + DisplayNote(message + 8); } return; } @@ -4349,9 +4359,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; }