Skip to content

Commit

Permalink
fix leaking object.cache file references (fixes #462)
Browse files Browse the repository at this point in the history
using fopen opens the object.cache a second time and naemon closes just one afterwards.
So with every write of the objects.cache file, one reference will be kept and prevents
the file from beeing deleted which finally fills the disk with deleted files.
Using fdopen solves the issue, since it just reuses the existing fd.
  • Loading branch information
sni committed Nov 13, 2024
1 parent f12c874 commit b9a6af3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/naemon/objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int fcache_objects(char *cache_file)
}

/* open the cache file for writing */
fp = (FILE *)fopen(tmp_file, "w");
fp = (FILE *)fdopen(fd, "w");
if (fp == NULL) {
unlink(tmp_file);
nm_log(NSLOG_CONFIG_WARNING, "Warning: Could not open object cache data file '%s' for writing!\n", tmp_file);
Expand Down

0 comments on commit b9a6af3

Please sign in to comment.