From d41654e7cb05e4b4fe537dc35c165b46ad0ac71f Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sat, 20 Jul 2024 13:01:27 +0200 Subject: OldestHistGame: handle the return of fscanf() --- FICS/gamedb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'FICS') diff --git a/FICS/gamedb.c b/FICS/gamedb.c index ee71af4..3b3c3aa 100644 --- a/FICS/gamedb.c +++ b/FICS/gamedb.c @@ -1542,8 +1542,13 @@ OldestHistGame(char *login) } if (fp != NULL) { - fscanf(fp, "%*d %*c %*d %*c %*d %*s %*s %*d %*d %*d %*d %*s " - "%*s %ld", &when); + if (fscanf(fp, "%*d %*c %*d %*c %*d %*s %*s %*d %*d %*d %*d " + "%*s %*s %ld", &when) != 1) { + warnx("%s: %s: failed to read 'when'", __func__, + &pFile[0]); + fclose(fp); + return 0L; + } fclose(fp); return when; } else -- cgit v1.2.3