| Age | Commit message (Collapse) | Author | Files | Lines |
|
When usbmuxd isn't running, the device_monitor thread waits for the
socket to appear by select()ing on an inotify fd. In a long-lived
process with many open descriptors (e.g. KDE's kwin_wayland, which
loads libusbmuxd via Solid's iMobileDevice backend), that fd can be
>= FD_SETSIZE (1024). FD_SET() on it is undefined behaviour, and with
_FORTIFY_SOURCE glibc aborts the whole process:
*** bit out of range 0 - FD_SETSIZE on fd_set ***: terminated
#8 __fortify_fail (libc)
#9 usbmuxd_listen_inotify src/libusbmuxd.c:944
#10 device_monitor src/libusbmuxd.c:1130
Here this took down the Wayland compositor (and with it the whole
desktop session) after ~4 weeks of uptime, when typing in the Overview
search triggered a KRunner plugin that initialised Solid.
poll() has no descriptor limit. This replaces the pselect() call with
poll() on the inotify fd and the wake pipe; the pselect() fallback shim
and the <sys/select.h> include become unused and are removed.
libimobiledevice-glue's socket code already uses poll() on non-Windows
platforms for the same reason.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
usbmuxd reports the network address of a device as a BSD sockaddr
([sa_len][sa_family]...), even when it runs on a different OS than the
client (e.g. macOS usbmuxd reached over TCP from Linux). libusbmuxd passed
it through unchanged, so consumers casting conn_data to struct sockaddr
(like libimobiledevice) got the wrong family on Linux and Windows.
Convert the address when parsing it, so conn_data holds a native sockaddr
for the platform the library runs on. On macOS nothing changes, on the
other BSDs only the family value is adjusted.
iproxy and inetcat now use conn_data directly and require this version of
the library. The format is documented in usbmuxd.h.
|
|
|
|
Credit to @PwnToday
|
|
|
|
|
|
If usbmuxd_events_unsubscribe() is called before the device monitor
thread has connected to usbmuxd, listenfd is still -1, so there is
nothing to shut down. Where thread_cancel() is not available (Windows,
or builds without pthread_cancel) unsubscribe then relies on clearing
`running`, but device_monitor() sets `running = 1` and `cancelling = 0`
itself when it starts and overwrites that. The thread goes on to
connect, sends Listen and blocks in receive_packet() forever, so
thread_join() never returns.
This is easy to hit with ideviceinstaller on Windows with a network
device and redirected stdout: the command completes before
idevice_wait_for_command_to_complete() subscribes, so subscribe and
unsubscribe happen back to back and the tool hangs on exit.
Fix this by:
- initializing `running`/`cancelling` in usbmuxd_events_subscribe()
under listener_mutex before the monitor thread is created;
- publishing listenfd in device_monitor() under the same mutex, and only
if no cancellation was requested in the meantime (otherwise close the
new socket and exit);
- setting `cancelling`/`running` and shutting down listenfd under the
mutex in usbmuxd_events_unsubscribe(), and only if the socket exists.
|
|
The primary purpose of this change is to support NetBSD.
No functional changes intended.
|
|
|
|
|
|
|
|
|
|
|
|
Also, make sure to return positive values from main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
than the usbmux fd
Thanks to @sleepinging for pointing this out.
|
|
|
|
Since socket_send already returns -errno, this function should pass it as is
|
|
download-artifact, checkout, and upload-artifact actions
|
|
|
|
|
|
|
|
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.
|
|
|
|
single socket
|
|
|
|
|
|
|
|
Thanks to @p0358 for reporting.
|
|
|
|
|
|
|
|
|
|
-Wint-conversion becomes an error by default in clang-16, causing the
program_invocation_short_name test to fail.
Bug: https://bugs.gentoo.org/893910
|
|
|
|
have an artifact
|
|
a string
Also remove some pointless casts and update some others
|
|
|
|
|
|
disabling CRLF conversion
|