From e68b78c51fb1e4f3258ab562acef18e443d972c7 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 4 Apr 2021 00:58:52 +0200 Subject: sync on save before rename, and check for errors on close MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libcontacts_save_contact.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libcontacts_save_contact.c b/libcontacts_save_contact.c index 5e27b85..b82a485 100644 --- a/libcontacts_save_contact.c +++ b/libcontacts_save_contact.c @@ -70,7 +70,13 @@ libcontacts_save_contact(struct libcontacts_contact *contact, const struct passw goto fail; } - close(fd), fd = -1; + if (fsync(fd)) + goto fail; + if (close(fd)) { + fd = -1; + goto fail; + } + fd = -1; if (rename(tmppath, path)) goto fail; -- cgit v1.2.3-70-g09d2