From 671f9a7eb79b5de29e16751619dce132b89106e1 Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 14 Feb 2017 16:12:18 +0100 Subject: [PATCH] Fix hc_path_create(), first close the file descriptor before unlinking the file itself --- src/shared.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/shared.c b/src/shared.c index bad8c01e9..67d47b3fc 100644 --- a/src/shared.c +++ b/src/shared.c @@ -246,7 +246,11 @@ bool hc_path_create (const char *path) { if (hc_path_exist (path) == true) return false; - if (creat (path, S_IRUSR | S_IWUSR) == -1) return false; + const int fd = creat (path, S_IRUSR | S_IWUSR); + + if (fd == -1) return false; + + close (fd); unlink (path);