diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2025-07-28 18:26:06 +0200 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2025-07-28 18:26:06 +0200 |
commit | 9ddfc63fb8efeb84c9a9ff16396b689c1565b4a6 (patch) | |
tree | 2fc92cf29ef0c0fe3869a6b3570e5a954c6dd3b2 | |
parent | 3b2fd45fff2691d0088fadc8239a062ad2f02c84 (diff) |
Restricted file permissions upon creation
-rw-r--r-- | FICS/ratings.c | 10 |
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; } |