mirror of
git://git.musl-libc.org/musl
synced 2025-04-01 22:48:38 +00:00
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 8fb28b0b3e
This commit is contained in:
parent
9b77aaca86
commit
074932c84d
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user