curl_easy_getopt: Handle API violation gracefully
authorChristian Grothoff <christian@grothoff.org>
Wed, 27 Nov 2013 22:28:26 +0000 (23:28 +0100)
committerSteve Holme <steve_holme@hotmail.com>
Wed, 27 Nov 2013 23:35:34 +0000 (23:35 +0000)
This fixes a NULL dereference in the case where the client asks for
CURLINFO_TLS_SESSION data after the (TLS) session has already been
destroyed (i.e. curl_easy_perform has already completed for this
handle). Instead of crashing, we now return a CURLSSLBACKEND_NONE
error.

lib/getinfo.c

index 6a4e72e..cd5a62a 100644 (file)
@@ -288,6 +288,9 @@ static CURLcode getinfo_slist(struct SessionHandle *data, CURLINFO info,
       tlsinfo->ssl_backend = CURLSSLBACKEND_NONE;
       tlsinfo->internals = NULL;
 
+      if(!conn)
+        break;
+
       /* Find the active ("in use") SSL connection, if any */
       while((sockindex < sizeof(conn->ssl) / sizeof(conn->ssl[0])) &&
             (!conn->ssl[sockindex].use))