mirror of
https://github.com/troglobit/libuev.git
synced 2026-11-06 15:50:52 +00:00
Fix leaking descriptors, use CLOEXEC
The signal and timer fd's used in libuEv were not created properly with the CLOEXEC flag. Hence, all forked off children calling exec*() could access all file descriptor, sockets, etc., used by the parent process. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
9fc5227343
commit
98c8e9f8b1
2 files changed
+2
-2
No files matched your search
@@ -52,7 +52,7 @@ int uev_signal_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int signo
|
|||||||
w->fd = -1;
|
w->fd = -1;
|
||||||
|
|
||||||
sigemptyset(&mask);
|
sigemptyset(&mask);
|
||||||
fd = signalfd(-1, &mask, SFD_NONBLOCK);
|
fd = signalfd(-1, &mask, SFD_NONBLOCK | SFD_CLOEXEC);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ int uev_timer_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int timeou
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
|
fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user