From 57642387b4605582b95bfcfc7481f8c89e056daf Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sat, 23 Mar 2024 13:56:59 +0100 Subject: strlcat() plus truncation checks --- FICS/comproc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'FICS') diff --git a/FICS/comproc.c b/FICS/comproc.c index 8e4711f..1009c46 100644 --- a/FICS/comproc.c +++ b/FICS/comproc.c @@ -350,13 +350,16 @@ com_stats_rating(char *hdr, statistics *stats, char *dest, const size_t dsize) if (stats->whenbest) { snprintf(tmp, sizeof tmp, " %d", stats->best); - strcat(dest, tmp); + strlcat(dest, tmp, dsize); strftime(tmp, sizeof tmp, " (%d-%b-%y)", localtime((time_t *) &stats->whenbest)); - strcat(dest, tmp); + strlcat(dest, tmp, dsize); } - strcat(dest, "\n"); + if (strlcat(dest, "\n", dsize) >= dsize) { + (void) fprintf(stderr, "FICS: %s (line %d): warning: strlcat() " + "truncated\n", __func__, __LINE__); + } } PUBLIC int -- cgit v1.2.3