mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 11:17:29 +02:00
Fix for a memory BIO and handle BIO chains
This commit is contained in:
24
src/bio.c
24
src/bio.c
@ -869,20 +869,34 @@ size_t wolfSSL_BIO_ctrl_pending(WOLFSSL_BIO *bio)
|
|||||||
|
|
||||||
long wolfSSL_BIO_get_mem_ptr(WOLFSSL_BIO *bio, WOLFSSL_BUF_MEM **ptr)
|
long wolfSSL_BIO_get_mem_ptr(WOLFSSL_BIO *bio, WOLFSSL_BUF_MEM **ptr)
|
||||||
{
|
{
|
||||||
|
WOLFSSL_BIO* front = bio;
|
||||||
|
long ret = WOLFSSL_FAILURE;
|
||||||
|
|
||||||
WOLFSSL_ENTER("wolfSSL_BIO_get_mem_ptr");
|
WOLFSSL_ENTER("wolfSSL_BIO_get_mem_ptr");
|
||||||
|
|
||||||
if (bio == NULL || ptr == NULL) {
|
if (bio == NULL || ptr == NULL) {
|
||||||
return WOLFSSL_FAILURE;
|
return WOLFSSL_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bio->type != WOLFSSL_BIO_MEMORY) {
|
/* start at end and work backwards to find a memory BIO in the BIO chain */
|
||||||
WOLFSSL_MSG("BIO is not memory buffer type");
|
while ((bio != NULL) && (bio->next != NULL)) {
|
||||||
return SSL_FAILURE;
|
bio = bio->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ptr = bio->mem_buf;
|
while (bio != NULL) {
|
||||||
|
|
||||||
return SSL_SUCCESS;
|
if (bio->type == WOLFSSL_BIO_MEMORY) {
|
||||||
|
*ptr = bio->mem_buf;
|
||||||
|
ret = WOLFSSL_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bio == front) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bio = bio->prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
WOLFSSL_API long wolfSSL_BIO_int_ctrl(WOLFSSL_BIO *bp, int cmd, long larg, int iarg)
|
WOLFSSL_API long wolfSSL_BIO_int_ctrl(WOLFSSL_BIO *bp, int cmd, long larg, int iarg)
|
||||||
|
Reference in New Issue
Block a user