[git] Assuan - branch, master, updated. libassuan-2.5.2-3-g5e48116

by NIIBE Yutaka cvs at cvs.gnupg.org
Fri Jan 25 03:39:57 CET 2019


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "IPC library used by GnuPG".

The branch, master has been updated
       via  5e48116051a476e1dcf5f66d9e21d8003b27ad20 (commit)
      from  23bf875954329458c0ac6c31e253cba44db8a648 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5e48116051a476e1dcf5f66d9e21d8003b27ad20
Author: NIIBE Yutaka <gniibe at fsij.org>
Date:   Fri Jan 25 11:34:15 2019 +0900

    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: 3381
    Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>

diff --git a/src/assuan-socket.c b/src/assuan-socket.c
index 7644ada..91b5f45 100644
--- a/src/assuan-socket.c
+++ b/src/assuan-socket.c
@@ -690,6 +690,8 @@ do_writen (assuan_context_t ctx, assuan_fd_t sockfd,
 }
 
 
+#define TIMEOUT_NOT_WAITING_SOCKS5_FOREVER 1 /* in second(s) */
+
 /* Connect using the SOCKS5 protocol. */
 static int
 socks5_connect (assuan_context_t ctx, assuan_fd_t sock,
@@ -713,9 +715,14 @@ socks5_connect (assuan_context_t ctx, assuan_fd_t sock,
                                    hostname. */
   size_t buflen, hostnamelen;
   int method;
+  fd_set fds;
+  struct timeval tv = { TIMEOUT_NOT_WAITING_SOCKS5_FOREVER, 0 };
 
   addru.addr = addr;
 
+  FD_ZERO (&fds);
+  FD_SET (HANDLE2SOCKET (sock), &fds);
+
   /* memset (&proxyaddr_in6, 0, sizeof proxyaddr_in6); */
   memset (&proxyaddr_in, 0, sizeof proxyaddr_in);
 
@@ -770,6 +777,25 @@ socks5_connect (assuan_context_t ctx, assuan_fd_t sock,
   ret = do_writen (ctx, sock, buffer, 3);
   if (ret)
     return ret;
+
+  /* There may be a different service at the port, which doesn't
+     respond.  Not to be bothred by such a service.  */
+  /* FIXME: Since the process may block on select, it should be
+     npth_select to release thread scheduling if nPth is enabled.
+     Ideally, select is better to be in the system hooks.  However, it
+     is considered OK to use select directly; Normal use case is three
+     steps: detect SOCKS5 service before nPth use, configure nPth
+     system hooks, and then use socks5_connect.  For the first call,
+     select indeed blocks, but it's only single thread.  For
+     succeeding calls, this select should soon return successfully.
+   */
+  ret = select (sock+1, &fds, NULL, NULL, &tv);
+  if (!ret)
+    {
+      gpg_err_set_errno (ETIMEDOUT);
+      return -1;
+    }
+
   ret = do_readn (ctx, sock, buffer, 2);
   if (ret)
     return ret;

-----------------------------------------------------------------------

Summary of changes:
 src/assuan-socket.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)


hooks/post-receive
-- 
IPC library used by GnuPG
http://git.gnupg.org




More information about the Gnupg-commits mailing list