Skip to content

Add custom BIO callback dispatching#10004

Open
julek-wolfssl wants to merge 1 commit intowolfSSL:masterfrom
julek-wolfssl:zd/21318
Open

Add custom BIO callback dispatching#10004
julek-wolfssl wants to merge 1 commit intowolfSSL:masterfrom
julek-wolfssl:zd/21318

Conversation

@julek-wolfssl
Copy link
Member

  • Route BIO_ctrl_pending, BIO_reset, and BIO_get_mem_data through the custom method's ctrlCb when set, enabling fully custom BIO types to handle these operations.
  • Add test_wolfSSL_BIO_custom_method that exercises a custom BIO with all callbacks (create, destroy, read, write, puts, gets, ctrl) and verifies each callback is invoked via bitfield tracking.

- Route BIO_ctrl_pending, BIO_reset, and BIO_get_mem_data through the custom method's ctrlCb when set, enabling fully custom BIO types to handle these operations.
- Add test_wolfSSL_BIO_custom_method that exercises a custom BIO with all callbacks (create, destroy, read, write, puts, gets, ctrl) and verifies each callback is invoked via bitfield tracking.
Copilot AI review requested due to automatic review settings March 18, 2026 17:29
@julek-wolfssl julek-wolfssl self-assigned this Mar 18, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for dispatching additional BIO operations (ctrl_pending, reset, get_mem_data) through a custom BIO method’s ctrlCb, and introduces a new API test exercising a fully-custom BIO method implementation.

Changes:

  • Route wolfSSL_BIO_ctrl_pending, wolfSSL_BIO_reset, and wolfSSL_BIO_get_mem_data through bio->method->ctrlCb when present.
  • Add test_wolfSSL_BIO_custom_method to validate callback invocation for a custom BIO method.
  • Register the new test in the ossl_bio test declarations.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
tests/api/test_ossl_bio.h Registers the new custom BIO method test in the ossl_bio test group.
tests/api/test_ossl_bio.c Adds a custom BIO implementation and a test validating callback dispatch and behavior.
src/bio.c Dispatches pending/reset/get_mem_data to a custom method ctrlCb when configured.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +1307 to +1308
WOLFSSL_MSG("Calling custom BIO ctrl pending callback");
return (size_t)bio->method->ctrlCb(bio, WOLFSSL_BIO_CTRL_PENDING, 0, NULL);
Comment on lines +1671 to +1673
/* free - should invoke destroyCb */
BIO_free(bio);
BIO_meth_free(method);
Comment on lines +1585 to +1599
switch (cmd) {
case BIO_CTRL_PENDING:
return (long)data->len;
case BIO_CTRL_RESET:
data->len = 0;
return WOLFSSL_SUCCESS;
case BIO_CTRL_FLUSH:
return 1;
case BIO_CTRL_INFO:
if (parg != NULL)
*(char**)parg = data->buf;
return (long)data->len;
default:
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants