summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2024-10-14 12:15:55 +0200
committerGravatar Nikias Bassen2024-10-14 12:15:55 +0200
commitcde0746b3c53b58347c9130d9fdf73a38cef9b81 (patch)
treed7fe2a849cebf7c0e3bb17703444bbe8f7cc89f4 /tools
parenta7f0543fb1ecb20ac7121c0fd77297200e0e43fc (diff)
downloadlibusbmuxd-cde0746b3c53b58347c9130d9fdf73a38cef9b81.tar.gz
libusbmuxd-cde0746b3c53b58347c9130d9fdf73a38cef9b81.tar.bz2
tools: Fix potential issue with select() in case the network fd is higher than the usbmux fd
Thanks to @sleepinging for pointing this out.
Diffstat (limited to 'tools')
-rw-r--r--tools/iproxy.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/iproxy.c b/tools/iproxy.c
index 1bb9e77..6849ef9 100644
--- a/tools/iproxy.c
+++ b/tools/iproxy.c
@@ -169,10 +169,11 @@ static void *acceptor_thread(void *arg)
FD_ZERO(&fds);
FD_SET(cdata->fd, &fds);
FD_SET(cdata->sfd, &fds);
+ int maxfd = cdata->fd > cdata->sfd ? cdata->fd : cdata->sfd;
while (1) {
fd_set read_fds = fds;
- int ret_sel = select(cdata->sfd+1, &read_fds, NULL, NULL, NULL);
+ int ret_sel = select(maxfd+1, &read_fds, NULL, NULL, NULL);
if (ret_sel < 0) {
perror("select");
break;