diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-11-28 07:09:37 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-11-28 07:09:37 +0100 |
commit | 3180478d8ed332e004c0d257c91b89d4a2f3a5cf (patch) | |
tree | c590fb6c657b70d6cf557b6e536cb36500488d43 /FICS | |
parent | 5afe65cfc5a34fd1a09bdd1aae29f3d62f5de77a (diff) |
GetPlayerInfo: made improvements
Diffstat (limited to 'FICS')
-rw-r--r-- | FICS/makerank.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/FICS/makerank.c b/FICS/makerank.c index 5f1f2f5..85938ce 100644 --- a/FICS/makerank.c +++ b/FICS/makerank.c @@ -46,13 +46,18 @@ GetPlayerInfo(char *fileName, ENTRY *e) } if (!strcmp(line, "v 1\n")) { - fgets(line, sizeof line, fp); - - sscanf(line, "%s", e->name); - - fgets(line, sizeof line, fp); - fgets(line, sizeof line, fp); - fgets(line, sizeof line, fp); + if (fgets(line, sizeof line, fp) == NULL || + sscanf(line, "%s", e->name) != 1) { + warnx("%s: fgets() or sscanf() error", __func__); + fclose(fp); + return 0; + } else if (fgets(line, sizeof line, fp) == NULL || + fgets(line, sizeof line, fp) == NULL || + fgets(line, sizeof line, fp) == NULL) { + warnx("%s: fgets() error", __func__); +// fclose(fp); +// return 0; + } if (fscanf(fp, "%d %*u %*u %*u %d %*u %*u %*u %*u %d %*u %*u " "%*u %d %*u %*u %*u %*u %d %*u %*u %*u %d %*u %*u %*u %*u " @@ -67,6 +72,8 @@ GetPlayerInfo(char *fileName, ENTRY *e) &(e->r[3].rating)) != 8) { fprintf(stderr, "OOPS: couldn't parse player file %s." "\n", fileName); + fclose(fp); + return 0; } } else { do { |