From 3b30aa0c238cd105ca9a8c3b381e7b6589c0afce Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Wed, 3 Jan 2024 04:06:48 +0100 Subject: Replaced sprintf() calls --- FICS/makerank.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'FICS/makerank.c') diff --git a/FICS/makerank.c b/FICS/makerank.c index 22dad8a..d8be7f6 100644 --- a/FICS/makerank.c +++ b/FICS/makerank.c @@ -128,8 +128,10 @@ LoadEntries(void) for (letter1 = 'a'; letter1 <= 'z'; letter1++) { printf("Loading %c's.\n", letter1); - sprintf(pathInput, "%s/%c", DEFAULT_PLAYERS, letter1); - sprintf(command, "ls -1 %s", pathInput); + + snprintf(pathInput, sizeof pathInput, "%s/%c", DEFAULT_PLAYERS, + letter1); + snprintf(command, sizeof command, "ls -1 %s", pathInput); if ((fpPlayerList = popen(command, "r")) == NULL) continue; @@ -147,8 +149,9 @@ LoadEntries(void) printf("File %c/%s: wrong directory.\n", letter1, e.name); } else { - sprintf(pathInput, "%s/%c/%s", DEFAULT_PLAYERS, - letter1, e.name); + snprintf(pathInput, sizeof pathInput, + "%s/%c/%s", DEFAULT_PLAYERS, letter1, + e.name); if (GetPlayerInfo(pathInput, &e)) { if ((list[n] = malloc(sizeof(ENTRY))) == @@ -184,7 +187,7 @@ SetComputers(int n) char line[100]; int i = 0; - sprintf(line, "sort -f %s", COMPUTER_FILE); + snprintf(line, sizeof line, "sort -f %s", COMPUTER_FILE); if ((fpComp = popen(line, "r")) == NULL) return 0; @@ -255,7 +258,8 @@ makerank(void) qsort(sortme, sortnum, sizeof(ENTRY *), sortfunc); printf("Saving to file.\n"); - sprintf(fName, "%s/rank.%s", DEFAULT_STATS, rnames[rtype]); + snprintf(fName, sizeof fName, "%s/rank.%s", DEFAULT_STATS, + rnames[rtype]); if ((fp = fopen(fName, "w")) == NULL) err(1, "%s: fopen", __func__); -- cgit v1.2.3