[Pkg-gnupg-commit] [libassuan] 08/19: Fix the nanosleep case of __assuan_usleep.

Eric Dorland eric at moszumanska.debian.org
Sat Nov 25 07:02:19 UTC 2017


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository libassuan.

commit 7b408d356094ab0ef0a07904a3ddf3832a8aa197
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Nov 15 15:43:24 2017 +0100

    Fix the nanosleep case of __assuan_usleep.
    
    * src/system-posix.c (__assuan_usleep): Handle full seconds.
    --
    
    This function would have failed for any value >= 1000000 because the
    nsec field is limited to 999999999 and the function fails for larger
    values.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>
---
 src/assuan-socket.c | 5 +++++
 src/system-posix.c  | 5 ++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/assuan-socket.c b/src/assuan-socket.c
index 6131e5b..147ec2a 100644
--- a/src/assuan-socket.c
+++ b/src/assuan-socket.c
@@ -745,6 +745,11 @@ socks5_connect (assuan_context_t ctx, assuan_fd_t sock,
       ret = _assuan_connect (ctx, HANDLE2SOCKET (sock),
                              proxyaddr, proxyaddrlen);
     }
+  /* If we get an EINPROGRESS here the caller is trying to do a
+   * non-blocking connect (e.g. for custom time out handling) which
+   * fails here.  The easiest fix would be to allow the client to tell
+   * us the timeout value and we do the timeout handling later on in the
+   * Socks protocol.  */
   if (ret)
     return ret;
   buffer[0] = 5; /* RFC-1928 VER field.  */
diff --git a/src/system-posix.c b/src/system-posix.c
index 52376da..65d2c8c 100644
--- a/src/system-posix.c
+++ b/src/system-posix.c
@@ -68,9 +68,8 @@ __assuan_usleep (assuan_context_t ctx, unsigned int usec)
     struct timespec req;
     struct timespec rem;
 
-    req.tv_sec = 0;
-    req.tv_nsec = usec * 1000;
-
+    req.tv_sec  = usecs / 1000000;
+    req.tv_nsec = (usecs % 1000000) * 1000;
     while (nanosleep (&req, &rem) < 0 && errno == EINTR)
       req = rem;
   }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/libassuan.git



More information about the Pkg-gnupg-commit mailing list