aboutsummaryrefslogtreecommitdiffstats
path: root/FICS/comproc.c
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2024-01-03 23:46:35 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2024-01-03 23:46:35 +0100
commit7e6efb47ced5f8142122dad277a71201c11c956c (patch)
tree59e45b2c58f1bd24a51abd795e4b1f92e865d2ab /FICS/comproc.c
parent923bd0f710d68a1273321455d5036cd867ae43cf (diff)
Added a destination size parameter to com_stats_andify()
Diffstat (limited to 'FICS/comproc.c')
-rw-r--r--FICS/comproc.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/FICS/comproc.c b/FICS/comproc.c
index 925ddc8..399ccc8 100644
--- a/FICS/comproc.c
+++ b/FICS/comproc.c
@@ -311,7 +311,7 @@ FindPlayer(int p, char *name, int *p1, int *connected)
}
PRIVATE void
-com_stats_andify(int *numbers, int howmany, char *dest)
+com_stats_andify(int *numbers, int howmany, char *dest, size_t dsize)
{
char tmp[10] = { '\0' };
@@ -319,7 +319,7 @@ com_stats_andify(int *numbers, int howmany, char *dest)
while (howmany--) {
snprintf(tmp, sizeof tmp, "%d", numbers[howmany]);
- strcat(dest, tmp);
+ strlcat(dest, tmp, dsize);
if (howmany > 1)
strlcpy(tmp, ", ", sizeof tmp);
@@ -328,7 +328,10 @@ com_stats_andify(int *numbers, int howmany, char *dest)
else
strlcpy(tmp, ".\n", sizeof tmp);
- strcat(dest, tmp);
+ if (strlcat(dest, tmp, dsize) >= dsize) {
+ (void) fprintf(stderr, "FICS: %s: warning: strlcat() "
+ "truncated\n", __func__);
+ }
}
}
@@ -404,7 +407,7 @@ com_stats(int p, param_list param)
}
pprintf(p, "%s is giving a simul: game%s ", parray[p1].name,
(t > 1 ? "s" : ""));
- com_stats_andify(numbers, t, tmp);
+ com_stats_andify(numbers, t, tmp, sizeof tmp);
pprintf(p, tmp);
} else if (parray[p1].game >= 0) {
g = parray[p1].game;
@@ -443,7 +446,7 @@ com_stats(int p, param_list param)
if (t) {
pprintf(p, "%s is observing game%s ", parray[p1].name,
(t > 1 ? "s" : ""));
- com_stats_andify(numbers, t, tmp);
+ com_stats_andify(numbers, t, tmp, sizeof tmp);
pprintf(p, tmp);
}
}