diff options
author | Daiki Ueno <dueno@redhat.com> | 2017-02-15 18:26:19 +0100 |
---|---|---|
committer | Daiki Ueno <ueno@gnu.org> | 2017-02-16 16:17:14 +0100 |
commit | 63b31ebfa1a978789cb31635fd95d00d7e398fa2 (patch) | |
tree | b738b9f416930c577441e50d7bf072049d2b7ee7 /trust | |
parent | 99aabc614cce4e0a9751d9409546c34abc1fe2db (diff) |
trust: Fix saving trust file on Windows
Diffstat (limited to 'trust')
-rw-r--r-- | trust/save.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/trust/save.c b/trust/save.c index 66c9050..57544e8 100644 --- a/trust/save.c +++ b/trust/save.c @@ -199,6 +199,8 @@ on_unique_try_rename (void *data, return -1; } + free (file->temp); + file->temp = strdup (path); return 1; /* All done */ } @@ -279,13 +281,14 @@ p11_save_finish_file (p11_save_file *file, ret = false; } - if (ret == true && - rename (file->temp, path) < 0) { - p11_message_err (errno, "couldn't complete writing file: %s", path); - ret = false; - } + if (ret == true && strcmp (file->temp, path) != 0) { + if (rename (file->temp, path) < 0) { + p11_message_err (errno, "couldn't complete writing file: %s", path); + ret = false; + } - unlink (file->temp); + unlink (file->temp); + } #endif /* OS_WIN32 */ } |