From 0247a14cff6ac6e8b32ec0623954d4dc9f223dbb Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Thu, 4 Apr 2024 03:49:21 +0200 Subject: Replaced sprintf() calls with snprintf() --- FICS/ratings.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/FICS/ratings.c b/FICS/ratings.c index 3d2fb08..e08bc71 100644 --- a/FICS/ratings.c +++ b/FICS/ratings.c @@ -329,7 +329,8 @@ save_ratings(void) FILE *fp; char fname[MAX_FILENAME_SIZE] = { '\0' }; - sprintf(fname, "%s/newratingsV%d_data", stats_dir, STATS_VERSION); + snprintf(fname, sizeof fname, "%s/newratingsV%d_data", stats_dir, + STATS_VERSION); if ((fp = fopen(fname, "w")) == NULL) { fprintf(stderr, "FICS: Can't write ratings data!\n"); @@ -405,7 +406,7 @@ rating_recalc(void) zero_stats(); for (c = 'a'; c <= 'z'; c++) { - sprintf(dname, "%s/%c", player_dir, c); + snprintf(dname, sizeof dname, "%s/%c", player_dir, c); if ((dirp = opendir(dname)) == NULL) continue; @@ -1177,7 +1178,7 @@ UpdateRank(int type, char *addName, statistics *sNew, char *delName) return; } - sprintf(TmpRankFile, "%s/tmpRank", sdir); + snprintf(TmpRankFile, sizeof TmpRankFile, "%s/tmpRank", sdir); if ((fptemp = fopen(TmpRankFile, "w")) == NULL) { fprintf(stderr, "Unable to open rank file for updating.\n"); @@ -1211,7 +1212,7 @@ UpdateRank(int type, char *addName, statistics *sNew, char *delName) fclose(fp); // XXX - sprintf(command, "mv %s %s", TmpRankFile, RankFile); + snprintf(command, sizeof command, "mv %s %s", TmpRankFile, RankFile); system(command); } #endif -- cgit v1.2.3