Comment on write_file_safe()'s actual safety

This commit is contained in:
Přemysl Eric Janouch 2024-02-10 06:16:27 +01:00
parent cb9d162a26
commit c5424e6992
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 2 additions and 0 deletions

View File

@ -3552,6 +3552,8 @@ write_file_safe (const char *filename, const void *data, size_t data_len,
{ {
// XXX: ideally we would also open the directory, use *at() versions // XXX: ideally we would also open the directory, use *at() versions
// of functions and call fsync() on the directory as appropriate // of functions and call fsync() on the directory as appropriate
// FIXME: this should behave similarly to mkstemp(), just with 0666;
// as it is, this function is not particularly safe
char *temp = xstrdup_printf ("%s.new", filename); char *temp = xstrdup_printf ("%s.new", filename);
bool success = write_file (temp, data, data_len, e); bool success = write_file (temp, data, data_len, e);
if (success && !(success = !rename (temp, filename))) if (success && !(success = !rename (temp, filename)))