aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--FICS/command.c11
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)