Skip to content

Static-analysis fixes#965

Merged
padelsbach merged 4 commits intowolfSSL:masterfrom
ejohnstown:static-fixes
May 8, 2026
Merged

Static-analysis fixes#965
padelsbach merged 4 commits intowolfSSL:masterfrom
ejohnstown:static-fixes

Conversation

@ejohnstown
Copy link
Copy Markdown
Contributor

@ejohnstown ejohnstown commented May 7, 2026

  • src/internal.c (F-413): DoDisconnect/DoUnimplemented now use GetUint32() instead of raw ato32() so short payloads return WS_BUFFER_E instead of reading past the buffer. DoDisconnect also parses the description and language-identifier strings with GetSkip(), so a record truncated after the reason code returns WS_BUFFER_E instead of being treated as success.
  • apps/wolfssh/wolfssh.c (F-214): config_print was printing keyFile twice; fixed to print pubKeyFile.
  • src/port.c (F-50): WS_MoveFileA leaked unicodeOldName on two error paths; now freed before returning.
  • apps/wolfsshd/auth.c (F-57): CheckPasswordUnix now ForceZeros storedHashCpy before freeing.

Issues: F-50, F-57, F-214, F-413

Copilot AI review requested due to automatic review settings May 7, 2026 18:26
ejohnstown added 3 commits May 7, 2026 11:32
WS_MoveFileA allocated unicodeOldName but did not free it when the
follow-up mbstowcs_s calls failed. Check the conversion result after
filling unicodeOldName, and free it before returning when the sizing
call for unicodeNewName fails.

Affected function: WS_MoveFileA.
Issue: F-50
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 applies a set of targeted static-analysis fixes across the wolfSSH codebase, primarily tightening bounds/error handling in packet decoding, correcting a config print bug, and addressing memory hygiene issues.

Changes:

  • Harden message decoding in src/internal.c by using GetUint32() for UNIMPLEMENTED/DISCONNECT parsing.
  • Fix Windows WS_MoveFileA() cleanup on conversion error paths to avoid leaking unicodeOldName.
  • Improve security hygiene by zeroing sensitive buffers before freeing in wolfsshd password auth; fix client config printing of pubKeyFile.

Reviewed changes

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

File Description
src/internal.c Switches parsing from raw ato32() to GetUint32() for safer bounds-checked decoding.
src/port.c Frees unicodeOldName on additional error paths in WS_MoveFileA() to prevent leaks.
apps/wolfsshd/auth.c Zeroes storedHashCpy prior to free to reduce sensitive-data exposure.
apps/wolfssh/wolfssh.c Corrects config_print() to print pubKeyFile instead of duplicating keyFile.

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

Comment thread src/internal.c
Comment thread src/internal.c Outdated
- Replace raw ato32() with GetUint32() to check len.
- Return WS_BUFFER_E on short payload instead of reading
  past buffer end.
- DoDisconnect: parse the description and language identifier
  strings with GetSkip() so a truncated record returns
  WS_BUFFER_E instead of being treated as success.

Issue: F-413
Copy link
Copy Markdown
Contributor

@yosuke-wolfssl yosuke-wolfssl left a comment

Choose a reason for hiding this comment

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

everything looks good

@padelsbach padelsbach merged commit 978ef5c into wolfSSL:master May 8, 2026
131 checks passed
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