Skip to content

Fix heap over read#234

Open
aidankeefe2022 wants to merge 1 commit into
wolfSSL:mainfrom
aidankeefe2022:fix-heap-over-read
Open

Fix heap over read#234
aidankeefe2022 wants to merge 1 commit into
wolfSSL:mainfrom
aidankeefe2022:fix-heap-over-read

Conversation

@aidankeefe2022
Copy link
Copy Markdown
Member

x509 name can look like this /CN=name/C=company the parsing function did not account for strings that had missing = at the end of the string /CN=name/Ccompany. This caused an issue where the parsing logic would attempt to access one passed the last byte of the string. There is now logic to explicitly catch when this is the case.

Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #234

Scan targets checked: wolfclu-bugs, wolfclu-src

No new issues found in the changed files. ✅

Copy link
Copy Markdown
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

This PR fixes malformed X.509 subject parsing in wolfCLU_ParseX509NameString to avoid reading past the end of a token when a subject component is missing =.

Changes:

  • Adds an explicit delimiter check after strcspn() so tokens without = fail safely.
  • Preserves existing error handling by freeing the partially built name and returning NULL.

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

Comment thread src/tools/clu_funcs.c
word = strtok_r(NULL, deli, &end)) {
tagSz = (int)strcspn(word, "=");
if (tagSz <= 0) {
if (tagSz <= 0 || word[tagSz] != '=') {
@cconlon
Copy link
Copy Markdown
Member

cconlon commented May 28, 2026

@aidankeefe2022, I agree with copilot above. Let's see if we can easily add a unit test to cover this edge case.

@cconlon cconlon assigned aidankeefe2022 and unassigned cconlon May 28, 2026
…t in a non-success program exit and added more clear error reporting
Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #234

Scan targets checked: wolfclu-bugs, wolfclu-src

No new issues found in the changed files. ✅

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.

5 participants