diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-11-23 09:42:42 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-11-23 09:42:42 +0100 |
commit | 93925a1a0c36a819294d7f2281260532e3330b6a (patch) | |
tree | 83a7231d45e51a7bf4444310885a3b3e10e0ebc3 /FICS/command.c | |
parent | 16b0c35da1f16d8b204e1dfcc303ef44e6b8a065 (diff) |
Improved rscan_news()
Diffstat (limited to 'FICS/command.c')
-rw-r--r-- | FICS/command.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/FICS/command.c b/FICS/command.c index 872c92c..88aae2e 100644 --- a/FICS/command.c +++ b/FICS/command.c @@ -708,12 +708,17 @@ rscan_news(FILE *fp, int p, int lc) long int lval = 0; time_t crtime = 0; - fgets(junk, MAX_LINE_SIZE, fp); + if (fgets(junk, sizeof junk, fp) == NULL || + feof(fp)) + return; + + _Static_assert(ARRAY_SIZE(count) > 9, "Unexpected array size"); - if (feof(fp)) + if (sscanf(junk, "%ld %9s", &lval, count) != 2) { + warnx("%s: sscanf() error: too few items", __func__); return; + } - sscanf(junk, "%ld %s", &lval, count); crtime = lval; if ((crtime - lc) < 0) |