From e9e27eafae7ecbc77b1a74c4abcd7fd2661ff1dd Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sat, 23 Mar 2024 11:53:44 +0100 Subject: Added param 'size' to append_holding_display() and replaced strcat() calls --- FICS/board.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/FICS/board.c b/FICS/board.c index 0e21926..b3ad95a 100644 --- a/FICS/board.c +++ b/FICS/board.c @@ -170,14 +170,15 @@ append_holding_machine(char *buf, const size_t size, int g, int c, int p) } PRIVATE char * -append_holding_display(char *buf, game_state_t *gs, int white) +append_holding_display(char *buf, const size_t size, game_state_t *gs, + int white) { if (white) - strcat(buf, "White holding: ["); + strlcat(buf, "White holding: [", size); else - strcat(buf, "Black holding: ["); - strcat(buf, holding_str(gs->holding[white ? 0 : 1])); - strcat(buf, "]\n"); + strlcat(buf, "Black holding: [", size); + strlcat(buf, holding_str(gs->holding[white ? 0 : 1]), size); + strlcat(buf, "]\n", size); return buf; } @@ -246,8 +247,10 @@ board_to_string(char *wn, char *bn, int wt, int bt, game_state_t *b, move_t *ml, } else bstring[0] = '\0'; - if (bh && !IsMachineStyle(style)) - append_holding_display(bstring, b, (orientation == BLACK)); + if (bh && !IsMachineStyle(style)) { + append_holding_display(bstring, sizeof bstring, b, + (orientation == BLACK)); + } if (styleFuncs[style] (b, ml)) return NULL; if (bh) { @@ -255,7 +258,7 @@ board_to_string(char *wn, char *bn, int wt, int bt, game_state_t *b, move_t *ml, append_holding_machine(bstring, sizeof bstring, b->gameNum, 0, 0); else { - append_holding_display(bstring, b, + append_holding_display(bstring, sizeof bstring, b, (orientation == WHITE)); } } -- cgit v1.2.3