aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2026-03-07 17:38:29 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2026-03-07 17:38:29 +0100
commit2f486e199529a456f7dcdc5c9eb5b82c2727fed1 (patch)
tree6be8d18b03b6a2abdd09ede2d8bb9cdcd96d8b41
parent1b49a3478621a50585947978c89cd094e1b5f75a (diff)
Improved psend_logoutfile()
-rw-r--r--FICS/utils.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/FICS/utils.c b/FICS/utils.c
index 679aa08..e2193ce 100644
--- a/FICS/utils.c
+++ b/FICS/utils.c
@@ -579,23 +579,29 @@ psend_logoutfile(int p, char *dir, char *file)
char fname[MAX_FILENAME_SIZE] = { '\0' };
char tmp[MAX_LINE_SIZE] = { '\0' };
+ if (file == NULL || strcmp(file, "") == 0) {
+ warnx("%s: error: no file", __func__);
+ return -1;
+ }
+
if (parray[p].last_file)
rfree(parray[p].last_file);
parray[p].last_file = NULL;
parray[p].last_file_byte = 0L;
if (dir)
- snprintf(fname, sizeof fname, "%s/%s", dir, file);
+ (void) snprintf(fname, sizeof fname, "%s/%s", dir, file);
else
- strlcpy(fname, file, sizeof fname);
+ (void) strlcpy(fname, file, sizeof fname);
if ((fp = fopen(fname, "r")) == NULL)
return -1;
- while (fgets(tmp, sizeof tmp, fp) != NULL && !feof(fp))
+ while (fgets(tmp, sizeof tmp, fp) != NULL)
net_send_string(parray[p].socket, tmp, 1);
- fclose(fp);
+ if (fclose(fp) != 0)
+ warn("%s: fclose() error", __func__);
return 0;
}