Reject empty generation strings.
[openssl.git] / ssl / bio_ssl.c
index e2831af7f3595e5b68e88374283092d525820063..7cf941d15b6b1e7579f1f3095d6e67207b0cd2f8 100644 (file)
@@ -125,7 +125,7 @@ static int ssl_free(BIO *a)
     if (bs->ssl != NULL)
         SSL_shutdown(bs->ssl);
     if (a->shutdown) {
-        if (a->init && (bs->ssl != NULL))
+        if (a->init)
             SSL_free(bs->ssl);
         a->init = 0;
         a->flags = 0;
@@ -292,7 +292,10 @@ static long ssl_ctrl(BIO *b, int cmd, long num, void *ptr)
         else if (ssl->handshake_func == ssl->method->ssl_accept)
             SSL_set_accept_state(ssl);
 
-        SSL_clear(ssl);
+        if(!SSL_clear(ssl)) {
+            ret = 0;
+            break;
+        }
 
         if (b->next_bio != NULL)
             ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
@@ -413,8 +416,7 @@ static long ssl_ctrl(BIO *b, int cmd, long num, void *ptr)
         break;
     case BIO_CTRL_DUP:
         dbio = (BIO *)ptr;
-        if (((BIO_SSL *)dbio->ptr)->ssl != NULL)
-            SSL_free(((BIO_SSL *)dbio->ptr)->ssl);
+        SSL_free(((BIO_SSL *)dbio->ptr)->ssl);
         ((BIO_SSL *)dbio->ptr)->ssl = SSL_dup(ssl);
         ((BIO_SSL *)dbio->ptr)->renegotiate_count =
             ((BIO_SSL *)b->ptr)->renegotiate_count;
@@ -500,10 +502,8 @@ BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx)
         goto err;
     return (ret);
  err:
-    if (buf != NULL)
-        BIO_free(buf);
-    if (ssl != NULL)
-        BIO_free(ssl);
+    BIO_free(buf);
+    BIO_free(ssl);
 #endif
     return (NULL);
 }
@@ -521,8 +521,7 @@ BIO *BIO_new_ssl_connect(SSL_CTX *ctx)
         goto err;
     return (ret);
  err:
-    if (con != NULL)
-        BIO_free(con);
+    BIO_free(con);
 #endif
     return (NULL);
 }
@@ -556,7 +555,8 @@ int BIO_ssl_copy_session_id(BIO *t, BIO *f)
     if ((((BIO_SSL *)t->ptr)->ssl == NULL) ||
         (((BIO_SSL *)f->ptr)->ssl == NULL))
         return (0);
-    SSL_copy_session_id(((BIO_SSL *)t->ptr)->ssl, ((BIO_SSL *)f->ptr)->ssl);
+    if(!SSL_copy_session_id(((BIO_SSL *)t->ptr)->ssl, ((BIO_SSL *)f->ptr)->ssl))
+        return 0;
     return (1);
 }