musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2013年06月26日 21:41:51 -0400
committerRich Felker <dalias@aerifal.cx>2013年06月26日 21:41:51 -0400
commit7c20a11801fd56cbadac5a6e88ddddf8656ac1bc (patch)
tree856af354be7ad0c88170eb43b5e59c7ad5a8f6a7
parenta033cd22aa0ecd9f494b74669d358e7e1c7e1335 (diff)
downloadmusl-7c20a11801fd56cbadac5a6e88ddddf8656ac1bc.tar.gz
fix temp file leak in sem_open on successful creation of new semaphore
Diffstat
-rw-r--r--src/thread/sem_open.c 4
1 files changed, 2 insertions, 2 deletions
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. */
generated by cgit v1.2.1 (git 2.18.0) at 2025年09月16日 21:06:02 +0000

AltStyle によって変換されたページ (->オリジナル) /