Skip to content

Commit

Permalink
tools: Fix potential issue with select() in case the network fd is hi…
Browse files Browse the repository at this point in the history
…gher than the usbmux fd

Thanks to @sleepinging for pointing this out.
  • Loading branch information
nikias committed Oct 14, 2024
1 parent a7f0543 commit cde0746
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/iproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit cde0746

Please sign in to comment.