Skip to content

Drop dead code found by Coverity - #1268

Open
ejohnstown wants to merge 2 commits into
wolfSSL:masterfrom
ejohnstown:sf25
Open

ejohnstown wants to merge 2 commits into
wolfSSL:masterfrom
ejohnstown:sf25

Conversation

@ejohnstown

@ejohnstown ejohnstown commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

wolfSSH_ProcessBuffer() validates its format argument before the decode chain runs, so the chain's trailing reject could never be reached. An unrelated dead store in the terminal-request test goes along with it.

  • internal.c: PEM becomes the decode chain's default arm and the unreachable WS_UNIMPLEMENTED_E return is removed (CID 653252).
  • tests/unit.c: the done: block in test_SendChannelTerminalRequestNoTty() is only entered on an already-failed path, so its result checks could never fire. Not a Coverity item.

wolfSSH_ProcessBuffer() rejects any format outside ASN1, PEM, RAW, and
OPENSSH before the decode chain runs, so the chain's trailing else could
never be reached. PEM becomes the chain's default arm, which keeps derSz
definitely assigned on every path into the decrypt step.

Issue: CID-653252
The done: block in test_SendChannelTerminalRequestNoTty() is only
entered with a descriptor still open on a path that already set an error
code, so the result checks guarding -1494 and -1495 could never be true.
Restore the descriptors and keep the original code.
Copilot AI lite review requested due to automatic review settings September 18, 2026 22:25

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.

Copilot review overview

🟢 Approval recommended

The changes remove confirmed unreachable/dead code without altering reachable behavior, and the surrounding validation/cleanup logic remains consistent.

Review effort: Lite
Findings: None

What changed in this PR

Removes two Coverity-identified dead-code paths: an unreachable decode-chain “reject” branch in wolfSSH_ProcessBuffer() and dead stores in a unit test cleanup path.

Changes:

  • src/internal.c: Treat PEM as the implicit remaining format after the existing upfront format validation, and drop the unreachable WS_UNIMPLEMENTED_E return.
  • tests/unit.c: Remove ineffective dup2() failure-to-result assignments in a done: cleanup path where result == 0 cannot occur.
File Description
tests/​unit.c Simplifies cleanup error handling by removing dead stores while preserving descriptor restoration behavior.
src/​internal.c Removes an unreachable return by relying on existing format validation and making PEM the decode-chain default arm.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

2 participants