From 3030ea490caca7a9747e8e7df0e5e859f94306a9 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Sat, 7 Oct 2000 06:55:01 +0000 Subject: [PATCH] If the rename failed in isc_file_renameunique() unlink the temporary file. --- lib/isc/unix/file.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/isc/unix/file.c b/lib/isc/unix/file.c index cde307250d..c83c1e8676 100644 --- a/lib/isc/unix/file.c +++ b/lib/isc/unix/file.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: file.c,v 1.23 2000/10/03 05:45:39 marka Exp $ */ +/* $Id: file.c,v 1.24 2000/10/07 06:55:01 marka Exp $ */ #include @@ -155,6 +155,7 @@ isc_file_renameunique(const char *file, char *templet) { int fd = -1; int res = 0; isc_result_t result = ISC_R_SUCCESS; + struct stat stats; fd = mkstemp(templet); if (fd == -1) { @@ -162,8 +163,10 @@ isc_file_renameunique(const char *file, char *templet) { } if (result == ISC_R_SUCCESS) { res = rename(file, templet); - if (res != 0) + if (res != 0) { + (void)unlink(templet); result = isc__errno2result(errno); + } } if (fd != -1) close(fd);