From 9bee883aee78de5c8fdbd7add5622237a740e75a Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sun, 10 Dec 2023 17:04:39 +0100 Subject: Check for truncation --- FICS/talkproc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'FICS/talkproc.c') diff --git a/FICS/talkproc.c b/FICS/talkproc.c index 68f8cb5..ec1a7b8 100644 --- a/FICS/talkproc.c +++ b/FICS/talkproc.c @@ -737,6 +737,7 @@ com_mailmess(int p, param_list param) char fname[MAX_FILENAME_SIZE]; char mdir[MAX_FILENAME_SIZE]; char subj[120]; + int ret, too_long; if (!parray[p].registered) { pprintf(p, "Only registered people can use the mailmess " @@ -751,9 +752,13 @@ com_mailmess(int p, param_list param) if (search_directory(mdir, filename, buffer, 1000)) { snprintf(subj, sizeof subj, "Your FICS messages from server %s", fics_hostname); - snprintf(fname, sizeof fname, "%s/%s", mdir, filename); - mail_file_to_user(p, subj, fname); - pprintf(p, "Messages sent to %s\n", parray[p].emailAddress); + ret = snprintf(fname, sizeof fname, "%s/%s", mdir, filename); + too_long = (ret < 0 || (size_t)ret >= sizeof fname); + if (!too_long) { + mail_file_to_user(p, subj, fname); + pprintf(p, "Messages sent to %s\n", + parray[p].emailAddress); + } } else { pprintf(p, "You have no messages.\n"); } -- cgit v1.2.3