From f4634db42320ddc2a93caca8611dec4f63aab6e9 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 23 Dec 2011 00:19:32 +0000 Subject: [PATCH] Fix a bug in Windows rename_file. It was returning before moving the file if the unlink succeeded. --- nmap-update/nmap-update.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nmap-update/nmap-update.c b/nmap-update/nmap-update.c index 6bb7276d8..b390bb836 100644 --- a/nmap-update/nmap-update.c +++ b/nmap-update/nmap-update.c @@ -1029,8 +1029,8 @@ static int rename_file(const char *from_filename, const char *to_filename) /* Windows rename doesn't remove the destination if it exists. */ errno = 0; rc = unlink(to_filename); - if (rc == 0 || errno == ENOENT) - return 0; + if (rc == -1 && errno != ENOENT) + return -1; return rename(from_filename, to_filename); }