aboutsummaryrefslogtreecommitdiff
path: root/crypto/bio/bf_readbuff.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/bio/bf_readbuff.c')
-rw-r--r--crypto/bio/bf_readbuff.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/crypto/bio/bf_readbuff.c b/crypto/bio/bf_readbuff.c
index 135ccef83bf3..2409c9db97cc 100644
--- a/crypto/bio/bf_readbuff.c
+++ b/crypto/bio/bf_readbuff.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2021-2024 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -222,10 +222,13 @@ static int readbuffer_gets(BIO *b, char *buf, int size)
char *p;
int i, j;
- if (size == 0)
+ if (buf == NULL || size == 0)
return 0;
--size; /* the passed in size includes the terminator - so remove it here */
ctx = (BIO_F_BUFFER_CTX *)b->ptr;
+
+ if (ctx == NULL || b->next_bio == NULL)
+ return 0;
BIO_clear_retry_flags(b);
/* If data is already buffered then use this first */