aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
Diffstat (limited to 'FICS')
-rw-r--r--FICS/comproc.c57
1 files changed, 34 insertions, 23 deletions
diff --git a/FICS/comproc.c b/FICS/comproc.c
index 619bd37..98a44bd 100644
--- a/FICS/comproc.c
+++ b/FICS/comproc.c
@@ -423,7 +423,8 @@ com_stats_rating(char *hdr, statistics *stats, char *dest, const size_t dsize)
{
char tmp[100] = { '\0' };
- snprintf(dest, dsize, "%-10s%4s %5.1f %4d %4d %4d %4d", hdr,
+ (void) snprintf(dest, dsize, "%-10s%4s %5.1f %4d %4d %4d %4d",
+ hdr,
ratstr(stats->rating),
stats->sterr,
stats->win,
@@ -434,8 +435,8 @@ com_stats_rating(char *hdr, statistics *stats, char *dest, const size_t dsize)
if (stats->whenbest) {
struct tm res = {0};
- snprintf(tmp, sizeof tmp, " %d", stats->best);
- strlcat(dest, tmp, dsize);
+ (void) snprintf(tmp, sizeof tmp, " %d", stats->best);
+ (void) strlcat(dest, tmp, dsize);
errno = 0;
@@ -470,26 +471,30 @@ com_stats(int p, param_list param)
connected = 1;
}
- snprintf(line, sizeof line, "\nStatistics for %-11s ", parray[p1].name);
+ (void) snprintf(line, sizeof line, "\nStatistics for %-11s ",
+ parray[p1].name);
if (connected && parray[p1].status == PLAYER_PROMPT) {
- snprintf(tmp, sizeof tmp, "On for: %s",
+ (void) snprintf(tmp, sizeof tmp, "On for: %s",
hms_desc(player_ontime(p1)));
- strlcat(line, tmp, sizeof line);
- snprintf(tmp, sizeof tmp, " Idle: %s\n",
+ (void) strlcat(line, tmp, sizeof line);
+ (void) snprintf(tmp, sizeof tmp, " Idle: %s\n",
hms_desc(player_idle(p1)));
} else {
time_t last;
if ((last = player_lastdisconnect(p1)) != 0) {
- snprintf(tmp, sizeof tmp, "(Last disconnected %s):\n",
+ (void) snprintf(tmp, sizeof tmp,
+ "(Last disconnected %s):\n",
strltime(&last));
} else
- strlcpy(tmp, "(Never connected.)\n", sizeof tmp);
+ (void) strlcpy(tmp, "(Never connected.)\n", sizeof tmp);
}
- strlcat(line, tmp, sizeof line);
- pprintf(p, "%s", line);
+ if (strlcat(line, tmp, sizeof line) >= sizeof line)
+ warnx("%s: error: strlcat() truncated", __func__);
+ else
+ pprintf(p, "%s", line);
if (parray[p1].simul_info.numBoards) {
t = 0;
@@ -850,29 +855,35 @@ plogins(int p, char *fname)
PUBLIC int
com_llogons(int p, param_list param)
{
- char fname[MAX_FILENAME_SIZE] = { '\0' };
+ char fname[MAX_FILENAME_SIZE] = { '\0' };
+ int ret;
(void) param; // XXX: unused
- snprintf(fname, sizeof fname, "%s/%s", stats_dir, STATS_LOGONS);
- return plogins(p, fname);
+ ret = snprintf(fname, sizeof fname, "%s/%s", stats_dir, STATS_LOGONS);
+
+ return (is_too_long(ret, sizeof fname) ? COM_FAILED :
+ plogins(p, fname));
}
PUBLIC int
com_logons(int p, param_list param)
{
- char fname[MAX_FILENAME_SIZE] = { '\0' };
+ char fname[MAX_FILENAME_SIZE] = { '\0' };
+ int ret = -1;
if (param[0].type == TYPE_WORD) {
- snprintf(fname, sizeof fname, "%s/player_data/%c/%s.%s",
+ ret = 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",
+ ret = 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);
+
+ return (is_too_long(ret, sizeof fname) ? COM_FAILED :
+ plogins(p, fname));
}
PRIVATE void
@@ -922,8 +933,8 @@ who_terse(int p, int num, int *plist, int type)
if (type == none) {
strlcpy(ptmp, " ", sizeof ptmp);
} else {
- snprintf(ptmp, sizeof ptmp, "%-4s", ratstrii(rat,
- parray[p1].registered));
+ (void) snprintf(ptmp, sizeof ptmp, "%-4s",
+ ratstrii(rat, parray[p1].registered));
if (parray[p1].simul_info.numBoards) {
strlcat(ptmp, "~", sizeof ptmp);
@@ -1919,10 +1930,10 @@ com_adhelp(int p, param_list param)
PUBLIC int
com_mailsource(int p, param_list param)
{
- char *buffer[1000];
+ char *buffer[1000] = { NULL };
char *iwant;
- char fname[MAX_FILENAME_SIZE];
- char subj[120];
+ char fname[MAX_FILENAME_SIZE] = { '\0' };
+ char subj[120] = { '\0' };
int count;
if (!parray[p].registered) {