cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-tracker mailing list Archives

[ curl-Bugs-2958179 ] SSL handshake may loop forever

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Fri, 26 Feb 2010 23:30:19 +0000

Bugs item #2958179, was opened at 2010-02-24 21:13
Message generated for change (Comment added) made by bagder
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=2958179&group_id=976

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: SSL/TLS
Group: bad behaviour
Status: Open
>Resolution: Accepted
Priority: 5
Private: No
Submitted By: Wesley Miaw (josuah)
Assigned to: Daniel Stenberg (bagder)
Summary: SSL handshake may loop forever

Initial Comment:
I've run into a problem where I want to be able to abort a connection attempt but are unable to do so because libcurl has a loop that runs either forever or until a set timeout has been reached. I am using the multi interface to allow my own threads to control the process, and for all other stages of connecting that I've encountered so far, the curl_multi_perform() function returns periodically allowing me to stop work if I wish to.

But ssluse.c's ossl_connect_common() function has a loop where it attempts to perform ossl_connect_step2() inside a loop. If the socket is non-blocking, it will do this until the timeout is hit (which may be forever).

I fixed this by changing the following:

    retcode = ossl_connect_step2(conn, sockindex);
    if(retcode)
      return retcode;

to

    return ossl_connect_step2(conn, sockindex);

There doesn't seem to be any problem with this as what you'll get from curl_multi_perform() is CURLM_CALL_MULTI_PERFORM indicating you should call curl_multi_perform() some more. I'm not sure what impact this has on curl_easy_perform() though.

Another solution, which maybe works with curl_easy_perform() if this one does not, is to have any registered progress callback called in this loop. The progress callback can return non-zero to make the call give up. But this is slightly less flexible because maybe I just want to do some other work before letting libcurl continue, and not to abort the entire transfer.

(BTW - Sorry for not replying to comments posted on the bug I filed earlier; I did not receive notification emails until it got closed.)

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

>Comment By: Daniel Stenberg (bagder)
Date: 2010-02-27 00:30

Message:
I agree, this is stupid in the multi interface case but I think we need it
for the easy interface (or do the loop in other place for easy interface).
I suggest we do this fix. What do you think?

diff -u -p -r1.252 ssluse.c
--- lib/ssluse.c 5 Feb 2010 09:33:36 -0000 1.252
+++ lib/ssluse.c 26 Feb 2010 23:28:33 -0000
@@ -2423,7 +2423,7 @@ ossl_connect_common(struct connectdata *
     }
 
     retcode = ossl_connect_step2(conn, sockindex);
- if(retcode)
+ if(retcode || (data->state.used_interface == Curl_if_multi))
       return retcode;
 
   } /* repeat step2 until all transactions are done. */

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

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=2958179&group_id=976
Received on 2010-02-27

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET