From e846acf0e4432c35247996c9ff6988820b6d354f Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 15 Nov 2012 12:26:30 +0100 Subject: [PATCH 1/1] Fix tcpip_rcvconnect for gnutls comstack It was broken in the non-blocking case. --- src/tcpip.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/tcpip.c b/src/tcpip.c index 492cfef..4efc19a 100644 --- a/src/tcpip.c +++ b/src/tcpip.c @@ -580,21 +580,20 @@ int tcpip_rcvconnect(COMSTACK h) #if HAVE_GNUTLS_H if (h->type == ssl_type && !sp->session) { - int res; gnutls_global_init(); - tcpip_create_cred(h); - gnutls_init(&sp->session, GNUTLS_CLIENT); gnutls_set_default_priority(sp->session); gnutls_credentials_set (sp->session, GNUTLS_CRD_CERTIFICATE, sp->cred_ptr->xcred); - /* cast to intermediate size_t to avoid GCC warning. */ gnutls_transport_set_ptr(sp->session, (gnutls_transport_ptr_t) (size_t) h->iofile); - res = gnutls_handshake(sp->session); + } + if (sp->session) + { + int res = gnutls_handshake(sp->session); if (res < 0) { if (ssl_check_error(h, sp, res)) -- 1.7.10.4