diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-07-12 18:46:38 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-07-12 18:46:38 +0200 |
commit | 238e49c7d88c55028591580ae1e7b62bf72967fe (patch) | |
tree | fd5912ba30d372f2860ae413bc8487043dd0247d /src/libmdsserver | |
parent | indices (diff) | |
download | mds-238e49c7d88c55028591580ae1e7b62bf72967fe.tar.gz mds-238e49c7d88c55028591580ae1e7b62bf72967fe.tar.bz2 mds-238e49c7d88c55028591580ae1e7b62bf72967fe.tar.xz |
fix race condition in prepare_reexec
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/libmdsserver/util.c | 4 |
1 files changed, 4 insertions, 0 deletions
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; |