boring icon indicating copy to clipboard operation
boring copied to clipboard

fix: BIO_set_retry_write when BIO_CTRL_FLUSH to allow writer returns WouldBlock on flush

Open ihciah opened this issue 2 years ago • 2 comments

A fix for rust-openssl can be found at https://github.com/sfackler/rust-openssl/pull/1922

This PR fixes a BIO_flush related issue. According to openssl doc(link):

BIO_flush(), because it can write data may return 0 or -1 indicating that the call should be retried later in a similar manner to BIO_write(). The BIO_should_retry() call should be used and appropriate action taken is the call fails.

We have to call BIO_set_retry_write on retriable_error like WouldBlock. Otherwise, when the flush returns WouldBlock, it will fail.

Since we usually wrap openssl with a TcpStream, there is no buffer inside and flush always returns Ok(()), this issue is not obvious. However, if users use a buffered io, the flush support will be essential.

ihciah avatar May 11 '23 09:05 ihciah

Does this require upstream boringssl to fix the status too? https://github.com/openssl/openssl/commit/bcbc7d60679b79fa4347e33c865306dce41ed985

kornelski avatar Jun 13 '25 08:06 kornelski

Does this require upstream boringssl to fix the status too? openssl/openssl@bcbc7d6

No. You can try if the test can pass.

ihciah avatar Jun 13 '25 13:06 ihciah