aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--FICS/ratings.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/FICS/ratings.c b/FICS/ratings.c
index 9410429..0ac1d9c 100644
--- a/FICS/ratings.c
+++ b/FICS/ratings.c
@@ -410,12 +410,20 @@ save_ratings(void)
{
FILE *fp;
char fname[MAX_FILENAME_SIZE] = { '\0' };
+ int fd;
snprintf(fname, sizeof fname, "%s/newratingsV%d_data", stats_dir,
STATS_VERSION);
- if ((fp = fopen(fname, "w")) == NULL) {
+ errno = 0;
+ fd = open(fname, O_WRONLY|O_CREAT, S_IWUSR|S_IRUSR);
+
+ if (fd < 0) {
+ warn("%s: can't write ratings data", __func__);
+ return;
+ } else if ((fp = fdopen(fd, "w")) == NULL) {
warn("%s: can't write ratings data", __func__);
+ close(fd);
return;
}