提交 b46fe860 编写于 作者: M Matt Caswell

Fix BIO_pop for SSL BIOs

The BIO_pop implementation assumes that the rbio still equals the next BIO
in the chain. While this would normally be the case, it is possible that it
could have been changed directly by the application. It also does not
properly cater for the scenario where the buffering BIO is still in place
for the write BIO.

Most of the existing BIO_pop code for SSL BIOs can be replaced by a single
call to SSL_set_bio(). This is equivalent to the existing code but
additionally handles the scenario where the rbio has been changed or the
buffering BIO is still in place.
Reviewed-by: NRich Salz <rsalz@openssl.org>
上级 eddef305
...@@ -338,16 +338,8 @@ static long ssl_ctrl(BIO *b, int cmd, long num, void *ptr) ...@@ -338,16 +338,8 @@ static long ssl_ctrl(BIO *b, int cmd, long num, void *ptr)
case BIO_CTRL_POP: case BIO_CTRL_POP:
/* Only detach if we are the BIO explicitly being popped */ /* Only detach if we are the BIO explicitly being popped */
if (b == ptr) { if (b == ptr) {
/* /* This will clear the reference we obtained during push */
* Shouldn't happen in practice because the rbio and wbio are the SSL_set_bio(ssl, NULL, NULL);
* same when pushed.
*/
if (ssl->rbio != ssl->wbio)
BIO_free_all(ssl->wbio);
if (next != NULL)
BIO_free(next);
ssl->wbio = NULL;
ssl->rbio = NULL;
} }
break; break;
case BIO_C_DO_STATE_MACHINE: case BIO_C_DO_STATE_MACHINE:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册