Skip to content

Commit

Permalink
Fix use-after-free in BIO_C_SET_SSL callback
Browse files Browse the repository at this point in the history
Since the BIO_SSL structure was renewed by `ssl_free(b)/ssl_new(b)`,
the `bs` pointer needs to be updated before assigning to `bs->ssl`.

Thanks to @suishixingkong for reporting the issue and providing a fix.

Closes openssl#10539

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from openssl#11746)
  • Loading branch information
mspncp committed May 7, 2020
1 parent 90fc2c2 commit 73d6b4e
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions ssl/bio_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ static long ssl_ctrl(BIO *b, int cmd, long num, void *ptr)
ssl_free(b);
if (!ssl_new(b))
return 0;
bs = BIO_get_data(b);
}
BIO_set_shutdown(b, num);
ssl = (SSL *)ptr;
Expand Down

0 comments on commit 73d6b4e

Please sign in to comment.