Skip to content

fixes for closing fd, sanity check init calls, buffer scope, sanity check argmunts passed in#223

Open
JacobBarthelmeh wants to merge 2 commits intowolfSSL:mainfrom
JacobBarthelmeh:fenrir
Open

fixes for closing fd, sanity check init calls, buffer scope, sanity check argmunts passed in#223
JacobBarthelmeh wants to merge 2 commits intowolfSSL:mainfrom
JacobBarthelmeh:fenrir

Conversation

@JacobBarthelmeh
Copy link
Copy Markdown
Contributor

No description provided.

@JacobBarthelmeh JacobBarthelmeh self-assigned this May 1, 2026
Copilot AI review requested due to automatic review settings May 1, 2026 21:28
@JacobBarthelmeh JacobBarthelmeh changed the title Fenrir fixes for closing fd, sanity check init calls, buffer scope, sanity check argmunts passed in May 1, 2026
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 hardens wolfCLU against a handful of crash/over-read scenarios caused by missing/overlong CLI arguments and lifetime/cleanup issues, and adds regression tests to ensure these cases fail gracefully.

Changes:

  • Add Python regression tests for ecparam -name overlong inputs and genkey invoked without a key-type argument.
  • Fix/mitigate multiple robustness issues in CLI code paths (argv bounds check in genkey, NUL-termination for ecparam curve names, stdin-to-BIO buffer lifetime for pkcs8, safer string concatenation in CSR extension printing).
  • Improve cleanup/defensive behavior in keygen callbacks and DH/DSA setup teardown, and avoid writing output when decrypt length validation fails.

Reviewed changes

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

Show a summary per file
File Description
tests/pkey/ecparam-test.py Adds regression test ensuring overlong curve names don’t crash.
tests/genkey_sign_ver/genkey-sign-ver-test.py Adds regression test ensuring wolfssl genkey without key type doesn’t crash.
src/x509/clu_request_setup.c Fixes XSTRLCAT usage to use destination buffer size consistently.
src/pkcs/clu_pkcs8.c Fixes stdin key buffer lifetime by heap-allocating and wiping on exit.
src/genkey/clu_genkey_setup.c Adds an argc guard to avoid dereferencing argv[2] when key type is missing.
src/genkey/clu_genkey.c Improves der buffer cleanup before realloc; closes files on XMSS error paths.
src/ecparam/clu_ecparam.c Ensures copied curve name is always NUL-terminated to avoid over-reads.
src/dsa/clu_dsa.c Tracks init state so only initialized objects are freed.
src/dh/clu_dh.c Tracks init state so only initialized objects are freed.
src/crypto/clu_decrypt.c Avoids writing output when an invalid decrypted length is detected.

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

Comment thread src/pkcs/clu_pkcs8.c
Comment on lines +183 to +184
wolfCLU_LogError("Unable to open pkcs8 file %s",
optarg);
Comment thread src/genkey/clu_genkey.c
Comment on lines +1440 to +1445
/* free any prior derBuf (from PRIV path or initial alloc)
* before reallocating for the public key */
if (derBuf != NULL) {
wolfCLU_ForceZero(derBuf, keySz);
XFREE(derBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
derBuf = NULL;
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 #223

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.

3 participants