aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2024-01-03 03:33:54 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2024-01-03 03:33:54 +0100
commit95b9d5d4fabd826a4ec073f8ebf97bd56c3ac247 (patch)
tree246f95fcaf723ee9442e3b071b929ca0eb27df07
parent0b31e8c8cd3311c23ab38ff5280f42d28b8a9297 (diff)
Check fgets() return value and use sizeof
-rw-r--r--FICS/makerank.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/FICS/makerank.c b/FICS/makerank.c
index b1aa8de..299e72e 100644
--- a/FICS/makerank.c
+++ b/FICS/makerank.c
@@ -36,12 +36,9 @@ GetPlayerInfo(char *fileName, ENTRY *e)
e->r[i].rating = 0;
}
- if ((fp = fopen(fileName, "r")) == NULL)
- return 0;
-
- fgets(line, 99, fp);
-
- if (feof(fp))
+ if ((fp = fopen(fileName, "r")) == NULL ||
+ fgets(line, sizeof line - 1, fp) == NULL ||
+ feof(fp))
return 0;
if (!strcmp(line, "v 1\n")) {