socks5: Implement timeout to detect bogus service.

Authored by gniibe on Jan 25 2019, 3:34 AM.


socks5: Implement timeout to detect bogus service.

* src/assuan-socket.c (TIMEOUT_NOT_WAITING_SOCKS5_FOREVER): New.
(socks5_connect): Call 'select' in order to not waiting response
  • GnuPG-bug-id: T3381
  • Signed-off-by: NIIBE Yutaka <>
aheinecke added inline comments.

Thank you very much for your quick fix. I think there might be a mistake here in the first argument. Should it not be simply "1" instead of sock+1?

For Windows this raises the warning:

/home/aheinecke/dev/main/src/libassuan/src/assuan-socket.c: In function 'socks5_connect':
/home/aheinecke/dev/main/src/libassuan/src/assuan-socket.c:792:21: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
   ret = select (sock+1, &fds, NULL, NULL, &tv);
/home/aheinecke/dev/main/src/libassuan/src/assuan-socket.c:792:17: warning: passing argument 1 of 'select' makes integer from pointer without a cast [-Wint-conversion]
   ret = select (sock+1, &fds, NULL, NULL, &tv);
In file included from /home/aheinecke/dev/main/src/libassuan/src/assuan-defs.h:34:0,
                 from /home/aheinecke/dev/main/src/libassuan/src/assuan-socket.c:50:
/usr/share/mingw-w64/include/winsock2.h:995:34: note: expected 'int' but argument is of type 'assuan_fd_t {aka void *}'
   WINSOCK_API_LINKAGE int WSAAPI select(int nfds,fd_set *readfds,fd_set *writefds,fd_set *exceptfds,const PTIMEVAL timeout);
werner added a subscriber: werner.Jan 25 2019, 1:52 PM
werner added inline comments.


nfds is the highest-numbered file descriptor in any of the three sets, plus 1.

To fix the warning we need to cast it - will do so.

aheinecke added inline comments.Jan 25 2019, 2:10 PM

Ah OK. Thanks for the explanation. I know why I let you two fix these isssues ;-)