diff options
author | Mattias Andrée <maandree@kth.se> | 2021-04-04 00:58:52 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-04-04 00:58:52 +0200 |
commit | e68b78c51fb1e4f3258ab562acef18e443d972c7 (patch) | |
tree | f4aef3d479dc48886407559dccedc79ede8715fb | |
parent | Add libcontacts_same_number (diff) | |
download | libcontacts-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.c | 8 |
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; |