aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2024-03-23 11:49:17 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2024-03-23 11:49:17 +0100
commit5e36f2d5f34d528f747b81536a1aa90324a84291 (patch)
tree71bfa7ed7cfc79af6bc960705dec1a8c87a0cdca /FICS
parent6065de405b32cab24c47c0875d814f1290fd21eb (diff)
Added param 'size' to append_holding_machine() and replaced strcat() calls
Diffstat (limited to 'FICS')
-rw-r--r--FICS/board.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/FICS/board.c b/FICS/board.c
index c9b2c78..0e21926 100644
--- a/FICS/board.c
+++ b/FICS/board.c
@@ -151,7 +151,7 @@ holding_str(int *holding)
}
PRIVATE char *
-append_holding_machine(char *buf, int g, int c, int p)
+append_holding_machine(char *buf, const size_t size, int g, int c, int p)
{
char tmp[50] = { '\0' };
game_state_t *gs = &garray[g].game_state;
@@ -159,13 +159,13 @@ append_holding_machine(char *buf, int g, int c, int p)
snprintf(tmp, sizeof tmp, "<b1> game %d white [%s] black [", (g + 1),
holding_str(gs->holding[0]));
strlcat(tmp, holding_str(gs->holding[1]), sizeof tmp);
- strcat(buf, tmp);
+ strlcat(buf, tmp, size);
if (p) {
snprintf(tmp, sizeof tmp, "] <- %c%s\n", "WB"[c], wpstring[p]);
- strcat(buf, tmp);
+ strlcat(buf, tmp, size);
} else
- strcat(buf, "]\n");
+ strlcat(buf, "]\n", size);
return buf;
}
@@ -202,7 +202,7 @@ update_holding(int g, int pieceCaptured)
gs->holding[c][p - 1]++;
tmp1[0] = '\0';
- append_holding_machine(tmp1, g, c, p);
+ append_holding_machine(tmp1, sizeof tmp1, g, c, p);
snprintf(tmp2, sizeof tmp2, "Game %d %s received: %s -> [%s]\n",
(g + 1),
@@ -252,7 +252,8 @@ board_to_string(char *wn, char *bn, int wt, int bt, game_state_t *b, move_t *ml,
return NULL;
if (bh) {
if (IsMachineStyle(style))
- append_holding_machine(bstring, b->gameNum, 0, 0);
+ append_holding_machine(bstring, sizeof bstring,
+ b->gameNum, 0, 0);
else {
append_holding_display(bstring, b,
(orientation == WHITE));