Commit 7ad410d6c6 for openssl.org
commit 7ad410d6c6a238260b2f7da547f4a38bd023b706
Author: Eugene Syromiatnikov <esyr@openssl.org>
Date: Mon Jan 26 09:48:53 2026 +0100
crypto/bio/bf_buff.c: drop extraneous ctx NULL check in buffer_ctrl()
b->ptr cannot be NULL, so, the check is not needed, drop it.
Reported by Coverity as a potential NULL dereference in ctx->ibuf_len
access.
Resolves: https://scan5.scan.coverity.com/#/project-view/65248/10222?selectedIssue=1680636
Fixes: f17230ae6c9f "Fix of EOF and retry handling in BIO implementations"
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Wed Jan 28 12:56:56 2026
(Merged from https://github.com/openssl/openssl/pull/29757)
diff --git a/crypto/bio/bf_buff.c b/crypto/bio/bf_buff.c
index ea6c72b0e0..00d0ec6e40 100644
--- a/crypto/bio/bf_buff.c
+++ b/crypto/bio/bf_buff.c
@@ -257,10 +257,10 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr)
if (ctx->ibuf_len > 0)
return 0;
/*
- * If there is no ctx or no next BIO, BIO_read() returns 0, which means
- * EOF, BIO_eof() should return 1 in this case.
+ * If there is no next BIO, BIO_read() returns 0, which means EOF,
+ * BIO_eof() should return 1 in this case.
*/
- if (ctx == NULL || b->next_bio == NULL)
+ if (b->next_bio == NULL)
return 1;
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
break;