aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2026-03-11 13:59:55 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2026-03-11 13:59:55 +0100
commit181596ddd7003d1523316f3b68bf477b53c14dbd (patch)
tree3ff2227fdd01eac8cc40ca9d53fc9a02e0aae991 /FICS
parent66355099ec3540c575b07efa7f214ffd6a3340ff (diff)
Improved GetRankFileName()
Diffstat (limited to 'FICS')
-rw-r--r--FICS/ratings.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/FICS/ratings.c b/FICS/ratings.c
index f8cc424..446a88d 100644
--- a/FICS/ratings.c
+++ b/FICS/ratings.c
@@ -1498,19 +1498,46 @@ CompareStats(char *name1, statistics *s1,
PRIVATE int
GetRankFileName(char *out, const size_t size, int type)
{
+ int ret;
+
+ if (out == NULL) {
+ warnx("%s: invalid arg: null pointer detected", __func__);
+ return -1;
+ }
+
switch (type) {
case TYPE_BLITZ:
- snprintf(out, size, "%s/rank.blitz", sdir);
+ ret = snprintf(out, size, "%s/rank.blitz", sdir);
+
+ if (is_too_long(ret, size)) {
+ warnx("%s: snprintf: truncated", __func__);
+ return -1;
+ }
+
return type;
case TYPE_STAND:
- snprintf(out, size, "%s/rank.std", sdir);
+ ret = snprintf(out, size, "%s/rank.std", sdir);
+
+ if (is_too_long(ret, size)) {
+ warnx("%s: snprintf: truncated", __func__);
+ return -1;
+ }
+
return type;
case TYPE_WILD:
- snprintf(out, size, "%s/rank.wild", sdir);
+ ret = snprintf(out, size, "%s/rank.wild", sdir);
+
+ if (is_too_long(ret, size)) {
+ warnx("%s: snprintf: truncated", __func__);
+ return -1;
+ }
+
return type;
default:
- return -1;
+ break;
}
+
+ return -1;
}
PUBLIC void