From 63b31ebfa1a978789cb31635fd95d00d7e398fa2 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Wed, 15 Feb 2017 18:26:19 +0100 Subject: trust: Fix saving trust file on Windows --- trust/save.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'trust') 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 */ } -- cgit v1.1