aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-04-04 00:58:52 +0200
committerMattias Andrée <maandree@kth.se>2021-04-04 00:58:52 +0200
commite68b78c51fb1e4f3258ab562acef18e443d972c7 (patch)
treef4aef3d479dc48886407559dccedc79ede8715fb
parentAdd libcontacts_same_number (diff)
downloadlibcontacts-e68b78c51fb1e4f3258ab562acef18e443d972c7.tar.gz
libcontacts-e68b78c51fb1e4f3258ab562acef18e443d972c7.tar.bz2
libcontacts-e68b78c51fb1e4f3258ab562acef18e443d972c7.tar.xz
sync on save before rename, and check for errors on close
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--libcontacts_save_contact.c8
1 files changed, 7 insertions, 1 deletions
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;