From 238e49c7d88c55028591580ae1e7b62bf72967fe Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 12 Jul 2015 18:46:38 +0200 Subject: fix race condition in prepare_reexec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/libmdsserver/util.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libmdsserver/util.c b/src/libmdsserver/util.c index 8af7b10..c5aee89 100644 --- a/src/libmdsserver/util.c +++ b/src/libmdsserver/util.c @@ -106,6 +106,10 @@ int prepare_reexec(void) fail_if (len < 0); /* ‘readlink() does not append a null byte to buf.’ */ self_exe[len] = '\0'; + /* Handle possible race condition: file was removed. */ + if (access(self_exe, F_OK) < 0) + if (!strcmp(self_exe + (len - 10), " (deleted)")) + self_exe[len - 10] = '\0'; return 0; fail: return -1; -- cgit v1.2.3-70-g09d2