diff options
author | Werner Koch <wk@gnupg.org> | 2017-11-15 15:43:24 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2017-11-15 15:43:24 +0100 |
commit | 7b408d356094ab0ef0a07904a3ddf3832a8aa197 (patch) | |
tree | ba0492d4eb6440981fce72f9693d6df96352d359 | |
parent | 87c2bb5708ff202651fca81d91d5f1e0c898cb07 (diff) | |
download | libassuan-7b408d356094ab0ef0a07904a3ddf3832a8aa197.tar.gz |
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@gnupg.org>
-rw-r--r-- | src/assuan-socket.c | 5 | ||||
-rw-r--r-- | 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; } |