diff options
author | Érico Rolim <ericonr@disroot.org> | 2020-12-24 01:18:04 -0300 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2021-01-30 17:29:55 -0500 |
commit | 074932c84d34273821e3bfc2511e60a5ce78b8d8 (patch) | |
tree | 12ae0b99750b11438247dc9bf493f37fbeca362d | |
parent | 9b77aaca86b53c367f23505c24dd3c02e240efad (diff) | |
download | musl-074932c84d34273821e3bfc2511e60a5ce78b8d8.tar.gz musl-074932c84d34273821e3bfc2511e60a5ce78b8d8.tar.xz musl-074932c84d34273821e3bfc2511e60a5ce78b8d8.zip |
fix possible fd leak via missing O_CLOEXEC in pthread_setname_np
the omission of the flag here seems to have been an oversight when the function was added in 8fb28b0b3e7a5e958fb844722a4b2ef9bc244af1
-rw-r--r-- | src/thread/pthread_setname_np.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/thread/pthread_setname_np.c b/src/thread/pthread_setname_np.c index 82d35e17..fc2d2306 100644 --- 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; |