aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/config_file.c
diff options
context:
space:
mode:
authorMitchell Wills <mwills@google.com>2015-08-25 00:24:30 (GMT)
committerJouni Malinen <j@w1.fi>2015-08-27 15:06:05 (GMT)
commita218e1ded44cc88072f4e1896fdd8bd24f1829ac (patch)
tree607da96fae809f1fa2b9dc719dc1c432e1bb8a87 /wpa_supplicant/config_file.c
parent6aaa661af1acc65403ad6f5557f356bd623ba97b (diff)
downloadhostap-a218e1ded44cc88072f4e1896fdd8bd24f1829ac.zip
hostap-a218e1ded44cc88072f4e1896fdd8bd24f1829ac.tar.gz
hostap-a218e1ded44cc88072f4e1896fdd8bd24f1829ac.tar.bz2
Make sure configuration is saved to storage device
Config file is written to a temp file and then it is renamed to the original config file. However, it is possible that the rename operation will be commited to storage while file data will be still in cache causing original config file to be empty or partially written in case of a system reboot without a clean shutdown. Make this less likely to occur by forcing the data to be written to the storage device before renaming the file. Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
Diffstat (limited to 'wpa_supplicant/config_file.c')
-rw-r--r--wpa_supplicant/config_file.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
index 2af187d..fb438ea 100644
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
@@ -1361,6 +1361,8 @@ int wpa_config_write(const char *name, struct wpa_config *config)
}
#endif /* CONFIG_NO_CONFIG_BLOBS */
+ os_fdatasync(f);
+
fclose(f);
if (tmp_name) {