Skip to content

Fix wolfSSL_BUF_MEM_grow_ex with WOLFSSL_NO_REALLOC#10770

Open
embhorn wants to merge 1 commit into
wolfSSL:masterfrom
embhorn:zd22032
Open

Fix wolfSSL_BUF_MEM_grow_ex with WOLFSSL_NO_REALLOC#10770
embhorn wants to merge 1 commit into
wolfSSL:masterfrom
embhorn:zd22032

Conversation

@embhorn

@embhorn embhorn commented Jun 24, 2026

Copy link
Copy Markdown
Member

Description

With the compatibility layer and WOLFSSL_NO_REALLOC enabled, there was a potential read out of the boundary in wolfSSL_BUF_MEM_grow_ex

Thanks to Pelioro for submitting this issue.

Fixes zd22032

Testing

Added sanitizer test for this config

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes an OpenSSL-compatibility-layer memory safety bug in wolfSSL_BUF_MEM_grow_ex() when WOLFSSL_NO_REALLOC is enabled, and adds CI coverage to catch it under ASAN.

Changes:

  • Prevent out-of-bounds reads in the WOLFSSL_NO_REALLOC grow path by copying only the existing valid content (buf->length).
  • Add an API regression test that triggers the malloc+copy+free path and is detectable under ASAN/valgrind.
  • Extend the GitHub Actions smoke-test matrix with an --enable-opensslextra + WOLFSSL_NO_REALLOC ASAN job.

Reviewed changes

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

File Description
tests/api.c Adds a regression test exercising BUF_MEM_grow() growth past buf->max to detect the prior over-read under sanitizers.
src/ssl.c Fixes the WOLFSSL_NO_REALLOC grow implementation to copy only buf->length bytes from the old buffer.
.github/workflows/smoke-test.yml Adds a new ASAN smoke-test configuration for --enable-opensslextra with -DWOLFSSL_NO_REALLOC.

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

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #10770

Scan targets checked: wolfssl-bugs, wolfssl-src

No new issues found in the changed files. ✅

@embhorn embhorn marked this pull request as ready for review June 24, 2026 19:37
@github-actions

Copy link
Copy Markdown

retest this please

@embhorn embhorn assigned wolfSSL-Bot and unassigned embhorn Jun 25, 2026
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.

4 participants