From c887a8a9fd5ed8058398ff57e643da821e6e2e09 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Wed, 3 Jan 2024 22:43:34 +0100 Subject: Reformatted functions and replaced sprintf() calls with snprintf() --- FICS/comproc.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/FICS/comproc.c b/FICS/comproc.c index 7f2a992..20385c3 100644 --- a/FICS/comproc.c +++ b/FICS/comproc.c @@ -684,24 +684,30 @@ plogins(int p, char *fname) return COM_OK; } -PUBLIC int com_llogons(int p, param_list param) +PUBLIC int +com_llogons(int p, param_list param) { - char fname[MAX_FILENAME_SIZE]; + char fname[MAX_FILENAME_SIZE] = { '\0' }; - sprintf(fname, "%s/%s", stats_dir, STATS_LOGONS); - return plogins(p, fname); + snprintf(fname, sizeof fname, "%s/%s", stats_dir, STATS_LOGONS); + return plogins(p, fname); } -PUBLIC int com_logons(int p, param_list param) +PUBLIC int +com_logons(int p, param_list param) { - char fname[MAX_FILENAME_SIZE]; + char fname[MAX_FILENAME_SIZE] = { '\0' }; - if (param[0].type == TYPE_WORD) { - sprintf(fname, "%s/player_data/%c/%s.%s", stats_dir, param[0].val.word[0], param[0].val.word, STATS_LOGONS); - } else { - sprintf(fname, "%s/player_data/%c/%s.%s", stats_dir, parray[p].login[0], parray[p].login, STATS_LOGONS); - } - return plogins(p, fname); + if (param[0].type == TYPE_WORD) { + snprintf(fname, sizeof fname, "%s/player_data/%c/%s.%s", + stats_dir, param[0].val.word[0], param[0].val.word, + STATS_LOGONS); + } else { + snprintf(fname, sizeof fname, "%s/player_data/%c/%s.%s", + stats_dir, parray[p].login[0], parray[p].login, + STATS_LOGONS); + } + return plogins(p, fname); } PRIVATE void -- cgit v1.2.3