From 9870a8aa2887849d59e1b7559ef042ffa4df151c Mon Sep 17 00:00:00 2001 From: Roy Carter Date: Mon, 9 Mar 2026 15:22:41 +0200 Subject: [PATCH] bio: fixed logic compatibility to openSSL for reset,pending and get data bio (flush was already correct) --- src/bio.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/bio.c b/src/bio.c index 02431dd38ae..d10c0d8fa7b 100644 --- a/src/bio.c +++ b/src/bio.c @@ -1300,9 +1300,15 @@ size_t wolfSSL_BIO_ctrl_pending(WOLFSSL_BIO *bio) #endif if (bio == NULL) { - return 0; + return WOLFSSL_FATAL_ERROR; } + if (bio->method != NULL && bio->method->ctrlCb != NULL) + { + WOLFSSL_MSG("Calling custom BIO ctrl pending callback"); + return (int)bio->method->ctrlCb(bio, WOLFSSL_BIO_CTRL_PENDING, 0, NULL); + } + if (bio->type == WOLFSSL_BIO_MD || bio->type == WOLFSSL_BIO_BASE64) { /* these are wrappers only, get next bio */ @@ -1713,6 +1719,12 @@ int wolfSSL_BIO_reset(WOLFSSL_BIO *bio) return WOLFSSL_BIO_ERROR; } + if (bio->method != NULL && bio->method->ctrlCb != NULL) + { + WOLFSSL_MSG("Calling custom BIO reset callback"); + return (int)bio->method->ctrlCb(bio, WOLFSSL_BIO_CTRL_RESET, 0, NULL); + } + switch (bio->type) { #ifndef NO_FILESYSTEM case WOLFSSL_BIO_FILE: @@ -2184,7 +2196,11 @@ int wolfSSL_BIO_get_mem_data(WOLFSSL_BIO* bio, void* p) if (bio == NULL) return WOLFSSL_FATAL_ERROR; - + if (bio->method != NULL && bio->method->ctrlCb != NULL) + { + WOLFSSL_MSG("Calling custom BIO get mem data callback"); + return (int)bio->method->ctrlCb(bio, WOLFSSL_BIO_CTRL_INFO, 0, p); + } mem_bio = bio; /* Return pointer from last memory BIO in chain */ while (bio->next) {