Skip to content

Static Analysis Fixes#988

Merged
padelsbach merged 2 commits into
wolfSSL:masterfrom
ejohnstown:config-parse
May 20, 2026
Merged

Static Analysis Fixes#988
padelsbach merged 2 commits into
wolfSSL:masterfrom
ejohnstown:config-parse

Conversation

@ejohnstown
Copy link
Copy Markdown
Contributor

  • wolfssh: fix leak of pre-allocated config->user and copy the argv user name into a heap buffer (F-4102).
  • wolfsshd: expose CheckAuthKeysLine under WOLFSSHD_UNIT_TEST and add coverage for match, mismatched key, and same-length last-byte-differs cases (F-4107).

Copilot AI review requested due to automatic review settings May 20, 2026 18:09
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 addresses static-analysis findings in the wolfSSH client and wolfSSHD by fixing config->user ownership/lifetime on the client side and adding unit-test exposure plus coverage for authorized-keys line comparison logic on the server side.

Changes:

  • wolfssh client: copy -l <user> into heap memory and free any prior config->user value to avoid leaks/invalid frees.
  • wolfsshd: expose CheckAuthKeysLine() under WOLFSSHD_UNIT_TEST and add unit tests covering match and key-mismatch scenarios (including same-length last-byte difference).
  • test harness: adjust test logging output and add Base64 helpers for generating authorized_keys-style lines.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
apps/wolfsshd/test/test_configuration.c Adds Base64-backed test cases for CheckAuthKeysLine() and updates logging helper.
apps/wolfsshd/auth.h Declares CheckAuthKeysLine() for unit tests under WOLFSSHD_UNIT_TEST.
apps/wolfsshd/auth.c Makes CheckAuthKeysLine() non-static under WOLFSSHD_UNIT_TEST to enable direct test coverage.
apps/wolfssh/wolfssh.c Fixes -l option handling to avoid leaking/freeing non-owned config->user pointers.

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

Comment thread apps/wolfssh/wolfssh.c
1. Fix where an already allocated config->user is leaked.
2. Copy the argv user name into a heap buffer.

Issue: F-4102
- Expose CheckAuthKeysLine under WOLFSSHD_UNIT_TEST so tests can link it.
- Add test_CheckAuthKeysLine covering match, different key, and same-length
  key differing only in the last byte.
- Route the test Log() to stderr instead of an unused local buffer.

Issue: F-4107
@padelsbach padelsbach merged commit 541f0ac into wolfSSL:master May 20, 2026
125 checks passed
@ejohnstown ejohnstown deleted the config-parse branch May 20, 2026 22:26
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