libusbmuxd/0001-inotify-Avoid-leaking-file-descriptor-to-child-proce.patch
Kou Wenqi a8c02ab3ce Fix leaking file descriptor to child processes
(cherry picked from commit 22522c86b8cd83a428f12d5b8ea5a50690eb86a8)
2024-07-18 16:52:31 +08:00

29 lines
866 B
Diff

From c8e627016edd1440c8faf6f9b8f4092a83e01164 Mon Sep 17 00:00:00 2001
From: David Edmundson <kde@davidedmundson.co.uk>
Date: Wed, 1 Nov 2023 14:32:43 +0000
Subject: [PATCH] inotify: Avoid leaking file descriptor to child processes
inotify_init creates a file descriptor which by default is not makes
with CLOEXEC. If the application using libusbmuxd spawns applications
this then leaks through.
---
src/libusbmuxd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libusbmuxd.c b/src/libusbmuxd.c
index d0cccd1..6f8197b 100644
--- a/src/libusbmuxd.c
+++ b/src/libusbmuxd.c
@@ -900,7 +900,7 @@ static int usbmuxd_listen_inotify()
return sfd;
sfd = -1;
- inot_fd = inotify_init ();
+ inot_fd = inotify_init1(IN_CLOEXEC);
if (inot_fd < 0) {
LIBUSBMUXD_DEBUG(1, "%s: Failed to setup inotify\n", __func__);
return -2;
--
2.27.0