aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--FICS/playerdb.c4
-rw-r--r--FICS/ratings.c13
2 files changed, 13 insertions, 4 deletions
diff --git a/FICS/playerdb.c b/FICS/playerdb.c
index 29e8d78..29e14f4 100644
--- a/FICS/playerdb.c
+++ b/FICS/playerdb.c
@@ -1721,7 +1721,7 @@ player_lastconnect(int p)
_Static_assert(19 < ARRAY_SIZE(ipstr),
"'ipstr' too small");
- if (fscanf(fp, "%d %19s " "%" SCNd64 " %d %19s\n", &inout,
+ if (fscanf(fp, ("%d %19s " "%" SCNd64 " %d %19s\n"), &inout,
loginName, &lval, &registered, ipstr) != 5) {
fprintf(stderr, "FICS: Error in login info format. %s"
"\n", fname);
@@ -1764,7 +1764,7 @@ player_lastdisconnect(int p)
_Static_assert(19 < ARRAY_SIZE(ipstr),
"'ipstr' too small");
- if (fscanf(fp, "%d %19s " "%" SCNd64 " %d %19s\n", &inout,
+ if (fscanf(fp, ("%d %19s " "%" SCNd64 " %d %19s\n"), &inout,
loginName, &lval, &registered, ipstr) != 5) {
fprintf(stderr, "FICS: Error in login info format. %s"
"\n", fname);
diff --git a/FICS/ratings.c b/FICS/ratings.c
index 2f82e62..a719be0 100644
--- a/FICS/ratings.c
+++ b/FICS/ratings.c
@@ -1488,7 +1488,8 @@ UpdateRank(int type, char *addName, statistics *sNew, char *delName)
char command[MAX_STRING_LENGTH];
char line[MAX_RANK_LINE] = { '\0' };
char login[MAX_LOGIN_NAME] = { '\0' };
- int comp;
+ int comp = 0;
+ int fd = -1;
statistics sCur;
if (GetRankFileName(RankFile, sizeof RankFile, type) < 0)
@@ -1501,9 +1502,17 @@ UpdateRank(int type, char *addName, statistics *sNew, char *delName)
snprintf(TmpRankFile, sizeof TmpRankFile, "%s/tmpRank", sdir);
- if ((fptemp = fopen(TmpRankFile, "w")) == NULL) {
+ errno = 0;
+ fd = open(TmpRankFile, O_WRONLY|O_CREAT, S_IWUSR|S_IRUSR);
+
+ if (fd < 0) {
+ warn("%s: open", __func__);
+ fclose(fp);
+ return;
+ } else if ((fptemp = fdopen(fd, "w")) == NULL) {
warn("%s: unable to open rank file for updating", __func__);
fclose(fp);
+ close(fd);
return;
}