diff --git a/libcontainer/nsenter/cloned_binary.c b/libcontainer/nsenter/cloned_binary.c index 04b75f7e2f9..72fbd015302 100644 --- a/libcontainer/nsenter/cloned_binary.c +++ b/libcontainer/nsenter/cloned_binary.c @@ -261,7 +261,7 @@ static int make_execfd(int *fdtype, int allowed) if (*fdtype & allowed) { fd = mkostemp(template, O_CLOEXEC); if (fd >= 0) { - if (!unlink(template)) + if (unlink(template) >= 0) return fd; close(fd); } @@ -314,7 +314,7 @@ static int clone_binary(void) allowed &= ~EFD_MEMFD; memfd = make_execfd(&fdtype, allowed); - if (memfd < 0) + if (memfd < 0 || fdtype == EFD_NONE) return -ENOTRECOVERABLE; binfd = open("/proc/self/exe", O_RDONLY | O_CLOEXEC);