]> git.ipfire.org Git - thirdparty/openssl.git/commit
Fix false success on zero BIO write
authorMounir IDRASSI <mounir.idrassi@idrix.fr>
Wed, 29 Apr 2026 09:39:37 +0000 (18:39 +0900)
committerAndrew Dinh <andrewd@openssl.org>
Mon, 3 Aug 2026 12:37:43 +0000 (19:37 +0700)
commit5f3db0d811329b600045842116a062520437c2a1
tree0cef89b3c321a40cd9abee2fc032eb68450b7b74
parent7ef104e779ce00b5e63cbc90586853a28c44284e
Fix false success on zero BIO write

The TLS record layer treated BIO_write returning 0 as success unless
the BIO retry flag was set. For a write with data pending in the write
buffer, this could report success to the application while leaving record
data pending internally.

Capture the pending buffer length before the transport write. If a
positive length write returns zero, return retry when the BIO retry flag
is set and fatal otherwise. Do not queue an SSL reason for the fatal
zero-without-retry case: a custom BIO can return zero without retry
without this implying an SSL library or protocol error, so SSL_get_error()
reports SSL_ERROR_SYSCALL with an empty error queue.

Preserve the KTLS empty fragment case where the pending length is already
zero and a zero byte write is expected to succeed.

For DTLS, the same zero return without retry condition is now treated as
fatal; the failed buffer is still dropped in the existing DTLS write error
path. This intentionally tightens the previous behavior, which could treat
the zero return as success.

Add regression coverage with a custom BIO that returns 0 without setting
retry for a positive length write.

Fixes #31009

Reviewed-by: Jakub Zelenka <jakub.zelenka@openssl.foundation>
Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Andrew Dinh <andrewd@openssl.org>
MergeDate: Mon Aug  3 12:37:56 2026
(Merged from https://github.com/openssl/openssl/pull/31021)
ssl/record/methods/tls_common.c
test/helpers/ssltestlib.c
test/helpers/ssltestlib.h
test/sslapitest.c