projects
/
musl
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9b77aac
)
fix possible fd leak via missing O_CLOEXEC in pthread_setname_np
author
Érico Rolim
<ericonr@disroot.org>
Thu, 24 Dec 2020 04:18:04 +0000
(
01:18
-0300)
committer
Rich Felker
<dalias@aerifal.cx>
Sat, 30 Jan 2021 22:29:55 +0000
(17:29 -0500)
the omission of the flag here seems to have been an oversight when the
function was added in
8fb28b0b3e7a5e958fb844722a4b2ef9bc244af1
src/thread/pthread_setname_np.c
patch
|
blob
|
history
diff --git
a/src/thread/pthread_setname_np.c
b/src/thread/pthread_setname_np.c
index
82d35e1
..
fc2d230
100644
(file)
--- a/
src/thread/pthread_setname_np.c
+++ b/
src/thread/pthread_setname_np.c
@@
-19,7
+19,7
@@
int pthread_setname_np(pthread_t thread, const char *name)
snprintf(f, sizeof f, "/proc/self/task/%d/comm", thread->tid);
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
- if ((fd = open(f, O_WRONLY)) < 0 || write(fd, name, len) < 0) status = errno;
+ if ((fd = open(f, O_WRONLY
|O_CLOEXEC
)) < 0 || write(fd, name, len) < 0) status = errno;
if (fd >= 0) close(fd);
pthread_setcancelstate(cs, 0);
return status;