From: Rich Felker Date: Thu, 27 Jun 2013 01:41:51 +0000 (-0400) Subject: fix temp file leak in sem_open on successful creation of new semaphore X-Git-Tag: v0.9.11~15 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=7c20a11801fd56cbadac5a6e88ddddf8656ac1bc;p=oweals%2Fmusl.git fix temp file leak in sem_open on successful creation of new semaphore --- diff --git a/src/thread/sem_open.c b/src/thread/sem_open.c index 66f12ee4..9a95d257 100644 --- a/src/thread/sem_open.c +++ b/src/thread/sem_open.c @@ -123,9 +123,9 @@ sem_t *sem_open(const char *name, int flags, ...) goto fail; } close(fd); - if (link(tmp, name) == 0) break; - e = errno; + e = link(tmp, name) ? errno : 0; unlink(tmp); + if (!e) break; /* Failure is only fatal when doing an exclusive open; * otherwise, next iteration will try to open the * existing file. */