Check to see that the OpenSSL session is setup correctly. Fixes LM-88.
authorMikael Hallendal <micke@imendio.com>
Sun, 29 Apr 2007 18:01:16 +0200
changeset 263 23192c7973c0
parent 262 d372a2b61b1d
child 264 d43d9fa98866
Check to see that the OpenSSL session is setup correctly. Fixes LM-88. If the SSL Context is not setup correctly the call to SSL_new will fail as well causing SSL_set_bio to segfault. Added a check to see that the context is not NULL and that the session is created properly.
loudmouth/lm-ssl-openssl.c
--- a/loudmouth/lm-ssl-openssl.c	Sun Apr 29 14:16:02 2007 +0200
+++ b/loudmouth/lm-ssl-openssl.c	Sun Apr 29 18:01:16 2007 +0200
@@ -180,7 +180,21 @@
 	BIO       *sbio;
 	GIOStatus  status;
 
+	if (!ssl->ctx) {
+		g_set_error (error,
+			     LM_ERROR, LM_ERROR_CONNECTION_OPEN,
+			     "No SSL Context for OpenSSL");
+		return FALSE;
+	}
+
 	ssl->session = SSL_new (ssl->ctx);
+	if (ssl->session == NULL) {
+		g_set_error (error,
+			     LM_ERROR, LM_ERROR_CONNECTION_OPEN,
+			     "Failed to create an SSL session through OpenSSL");
+		return FALSE;
+	}
+	
 	sbio = BIO_new_socket (fd, BIO_NOCLOSE);
 	SSL_set_bio (ssl->session, sbio, sbio);