Home GnuPG

socks5: Implement timeout to detect bogus service.

Description

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
forever.
  • GnuPG-bug-id: T3381
  • Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>

Event Timeline

aheinecke added inline comments.
/src/assuan-socket.c
792

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 inline comments.
/src/assuan-socket.c
792

No:

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.

/src/assuan-socket.c
792

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