From a8c02ab3ce36ea44627de7c59f675f91078e7cbd Mon Sep 17 00:00:00 2001 From: Kou Wenqi Date: Mon, 8 Jul 2024 17:34:09 +0800 Subject: [PATCH] Fix leaking file descriptor to child processes (cherry picked from commit 22522c86b8cd83a428f12d5b8ea5a50690eb86a8) --- ...aking-file-descriptor-to-child-proce.patch | 28 +++++++++++++++++++ libusbmuxd.spec | 9 ++++-- 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 0001-inotify-Avoid-leaking-file-descriptor-to-child-proce.patch diff --git a/0001-inotify-Avoid-leaking-file-descriptor-to-child-proce.patch b/0001-inotify-Avoid-leaking-file-descriptor-to-child-proce.patch new file mode 100644 index 0000000..a9f7368 --- /dev/null +++ b/0001-inotify-Avoid-leaking-file-descriptor-to-child-proce.patch @@ -0,0 +1,28 @@ +From c8e627016edd1440c8faf6f9b8f4092a83e01164 Mon Sep 17 00:00:00 2001 +From: David Edmundson +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 + diff --git a/libusbmuxd.spec b/libusbmuxd.spec index dd08bd7..f5fac67 100644 --- a/libusbmuxd.spec +++ b/libusbmuxd.spec @@ -1,11 +1,13 @@ Name: libusbmuxd Version: 2.0.2 -Release: 3 +Release: 4 Summary: software protocol library and tools to communicate with iOS devices natively License: LGPLv2+ and GPLv2+ URL: http://www.libimobiledevice.org/ Source0: https://github.com/libimobiledevice/%{name}/archive/%{version}.tar.gz +Patch1: 0001-inotify-Avoid-leaking-file-descriptor-to-child-proce.patch + BuildRequires: gcc libplist-devel >= 2.2.0 autoconf automake libtool Provides: %{name}-utils Obsoletes: %{name}-utils @@ -25,7 +27,7 @@ Obsoletes: usbmuxd-devel < 1.0.9 provide head files or other files to support for development with %{name}. %prep -%setup -q +%autosetup -n %{name}-%{version} -p1 NOCONFIGURE=1 ./autogen.sh %build @@ -59,6 +61,9 @@ make check %{_libdir}/libusbmuxd-2.0.so %changelog +* Mon Jul 8 2024 kouwenqi - 2.0.2-4 +- Fix leaking file descriptor to child processes + * Mon Apr 18 2022 Chenxi Mao - 2.0.2-3 - Remove self-dependency