X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=ssl%2Fbio_ssl.c;h=639b10556a30a257a961c927091dbbf12b8d2829;hp=99f8b5e524ec9dc53ff91020b2e814cd77892974;hb=6b33d10686993191a99ad758cb59fb89c3d7abda;hpb=69f682374868ba2b19a8aeada496bf03dbb037cf diff --git a/ssl/bio_ssl.c b/ssl/bio_ssl.c index 99f8b5e524..639b10556a 100644 --- a/ssl/bio_ssl.c +++ b/ssl/bio_ssl.c @@ -101,14 +101,12 @@ BIO_METHOD *BIO_f_ssl(void) static int ssl_new(BIO *bi) { - BIO_SSL *bs; + BIO_SSL *bs = OPENSSL_zalloc(sizeof(*bs)); - bs = (BIO_SSL *)OPENSSL_malloc(sizeof(BIO_SSL)); if (bs == NULL) { BIOerr(BIO_F_SSL_NEW, ERR_R_MALLOC_FAILURE); return (0); } - memset(bs, 0, sizeof(BIO_SSL)); bi->init = 0; bi->ptr = (char *)bs; bi->flags = 0; @@ -125,13 +123,12 @@ 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; } - if (a->ptr != NULL) - OPENSSL_free(a->ptr); + OPENSSL_free(a->ptr); return (1); } @@ -292,7 +289,7 @@ 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); - if(!SSL_clear(ssl)) { + if (!SSL_clear(ssl)) { ret = 0; break; } @@ -416,8 +413,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; @@ -503,10 +499,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); } @@ -524,8 +518,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); } @@ -559,7 +552,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); }