From 551f882ff20ac6f902e38e6591fe57484a1da2ef Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Mon, 2 Dec 2024 14:37:25 +0100 Subject: player_read: fixed ignored fgets() retvals --- FICS/playerdb.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'FICS/playerdb.c') diff --git a/FICS/playerdb.c b/FICS/playerdb.c index e1da179..a82f3b9 100644 --- a/FICS/playerdb.c +++ b/FICS/playerdb.c @@ -964,7 +964,11 @@ player_read(int p, char *name) parray[p].registered = 1; // Lets load the file - fgets(line, sizeof line, fp); // Ok, so which version file? + if (fgets(line, sizeof line, fp) == NULL) { // Ok, so which version + warnx("%s: fgets() error", __func__); // file? + fclose(fp); + return -1; + } if (line[0] == 'v') sscanf(line, "%*c %d", &version); @@ -996,7 +1000,9 @@ player_read(int p, char *name) value = eatwhite(value); stolower(attr); got_attr_value_player(p, attr, value, fp, fname); - fgets(line, sizeof line, fp); + + if (fgets(line, sizeof line, fp) == NULL) + break; } while (!feof(fp)); } -- cgit v1.2.3