diff options
author | Nick Zitzmann <nick@chronosnet.com> | 2013-01-28 19:34:35 -0700 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2013-01-29 09:05:59 +0100 |
commit | 163a1dca5fc708f99db9e6a67d368e29f90e345e (patch) | |
tree | 3ce23dd5b8eae88424d39d8caaa1eae33245575e | |
parent | 23a47ef01b22a1eb3e6a1005631f76a4f93d89f5 (diff) |
darwinssl: Fix bug where packets were sometimes transmitted twice
There was a bug where, if SSLWrite() returned errSSLWouldBlock but did
succeed in transmitting at least something, then we'd incorrectly
resend the packet. Now we never take errSSLWouldBlock as a sign that
nothing was transferred to/from the server.
Bug: http://curl.haxx.se/mail/lib-2013-01/0295.html
Reported by: Bruno de Carvalho
-rw-r--r-- | lib/curl_darwinssl.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/curl_darwinssl.c b/lib/curl_darwinssl.c index e8fa2758b..827c876e0 100644 --- a/lib/curl_darwinssl.c +++ b/lib/curl_darwinssl.c @@ -5,8 +5,8 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2012, Nick Zitzmann, <nickzman@gmail.com>. - * Copyright (C) 2012, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 2012-2013, Nick Zitzmann, <nickzman@gmail.com>. + * Copyright (C) 2012-2013, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -1383,12 +1383,14 @@ static ssize_t darwinssl_send(struct connectdata *conn, { /*struct SessionHandle *data = conn->data;*/ struct ssl_connect_data *connssl = &conn->ssl[sockindex]; - size_t processed; + size_t processed = 0UL; OSStatus err = SSLWrite(connssl->ssl_ctx, mem, len, &processed); if(err != noErr) { switch (err) { - case errSSLWouldBlock: /* we're not done yet; keep sending */ + case errSSLWouldBlock: /* return how much we sent (if anything) */ + if(processed) + return (ssize_t)processed; *curlcode = CURLE_AGAIN; return -1; break; @@ -1411,12 +1413,14 @@ static ssize_t darwinssl_recv(struct connectdata *conn, { /*struct SessionHandle *data = conn->data;*/ struct ssl_connect_data *connssl = &conn->ssl[num]; - size_t processed; + size_t processed = 0UL; OSStatus err = SSLRead(connssl->ssl_ctx, buf, buffersize, &processed); if(err != noErr) { switch (err) { - case errSSLWouldBlock: /* we're not done yet; keep reading */ + case errSSLWouldBlock: /* return how much we read (if anything) */ + if(processed) + return (ssize_t)processed; *curlcode = CURLE_AGAIN; return -1; break; |