static int ssl_new(BIO *bi)
{
- BIO_SSL *bs;
+ BIO_SSL *bs = OPENSSL_malloc(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));
+ memset(bs, 0, sizeof(*bs));
bi->init = 0;
bi->ptr = (char *)bs;
bi->flags = 0;
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);
}
BIO_clear_retry_flags(b);
-#if 0
- if (!SSL_is_init_finished(ssl)) {
-/* ret=SSL_do_handshake(ssl); */
- if (ret > 0) {
-
- outflags = (BIO_FLAGS_READ | BIO_FLAGS_SHOULD_RETRY);
- ret = -1;
- goto end;
- }
- }
-#endif
-/* if (ret > 0) */
ret = SSL_read(ssl, out, outl);
switch (SSL_get_error(ssl, ret)) {
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);
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;
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);
}
goto err;
return (ret);
err:
- if (con != NULL)
- BIO_free(con);
+ BIO_free(con);
#endif
return (NULL);
}
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);
}