[balsa] Check for NULL value returned by SSL_CTX_new



commit 5ddada899c1e586b3a95e5e584989938ac3e4b1c
Author: Zhouyang Jia <jiazhouyang09 gmail com>
Date:   Sat Aug 5 12:30:38 2017 -0400

    Check for NULL value returned by SSL_CTX_new
    
        * libbalsa/imap/imap-tls.c (imap_create_ssl): check for NULL
        value from SSL_CTX_new.
    
    Signed-off-by: Peter Bloomfield <PeterBloomfield bellsouth net>

 ChangeLog                |    5 +++++
 libbalsa/imap/imap-tls.c |    5 +++++
 2 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c99386b..61e3cdd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-08-05  Zhouyang Jia <jiazhouyang09 gmail com>
+
+       * libbalsa/imap/imap-tls.c (imap_create_ssl): check for NULL
+       value from SSL_CTX_new.
+
 2017-08-03  Peter Bloomfield  <pbloomfield bellsouth net>
 
        Save and restore the spell checking language when built with the
diff --git a/libbalsa/imap/imap-tls.c b/libbalsa/imap/imap-tls.c
index b6de4a3..47b3208 100644
--- a/libbalsa/imap/imap-tls.c
+++ b/libbalsa/imap/imap-tls.c
@@ -177,6 +177,11 @@ imap_create_ssl(void)
     /* Note: SSLv23_client_method() actually enables *all* protocols, including
      * SSLv(2|3) and TLSv1.(0|1|2), so we must switch all unsafe ones off */
     global_ssl_context = SSL_CTX_new (SSLv23_client_method ());
+    if(!global_ssl_context) {
+        fprintf(stderr, "Could not initialize SSL Context.\n");
+        return NULL;
+    }
+
 #ifdef ENABLE_SSL3
     SSL_CTX_set_options(global_ssl_context, SSL_OP_ALL|SSL_OP_NO_SSLv2);
 #else


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]