commit - 3b92b4c38e62976d3299c99ca9b91f85bafe2df7
commit + d7cada912ae751364577affaf215279bb0277122
blob - b6469338e78e8b750eecda616bdce1ed848a7765
blob + 2478cabe77032e16271ce9c08dd85232ecfa5c47
--- FICS/adminproc.c
+++ FICS/adminproc.c
{
FILE *fp;
char filename[MAX_FILENAME_SIZE] = { '\0' };
+ int fd;
ASSERT(parray[p].adminLevel >= ADMIN_ADMIN);
msnprintf(filename, sizeof filename, "%s/adminnews.%d",
news_dir,
param[0].val.integer);
- if ((fp = fopen(filename, "w")) != NULL) {
+ fd = open(filename, O_WRONLY|O_CREAT, S_IWUSR|S_IRUSR);
+ if (fd < 0)
+ return COM_FAILED;
+ else if ((fp = fdopen(fd, "w")) != NULL) {
fprintf(fp, "%s\n", param[1].val.string);
fclose(fp);
- }
+ } else
+ close(fd);
}
} else {
if (param[0].val.integer > num_news) {
msnprintf(filename, sizeof filename, "%s/news.%d",
news_dir,
param[0].val.integer);
- if ((fp = fopen(filename, "w")) != NULL) {
+ fd = open(filename, O_WRONLY|O_CREAT, S_IWUSR|S_IRUSR);
+ if (fd < 0)
+ return COM_FAILED;
+ else if ((fp = fdopen(fd, "w")) != NULL) {
fprintf(fp, "%s\n", param[1].val.string);
fclose(fp);
- }
+ } else
+ close(fd);
}
}