Fix DEADCODE and TOCTOU defects reported by Coverity - #1134
Merged
Conversation
- noneOk was only ever set inside the WOLFSSH_ALLOW_NONE_CIPHER guard, so usableCount++ was unreachable in the default build. - Move the whole ID_NONE arm under the guard and drop noneOk. Behavior is unchanged in both builds. Issues: CID-651702
- Scenarios 1 and 5 fopen() once and fstat() that handle instead of stat()ing the path a second time. - A failed open is now a logged error rather than an indirect rd == 0. - The FIFO lstat() and failPath existence test stay as they are: neither has a descriptor to stat, and mkdtemp()'s 0700 directory makes them unraceable. Issues: CID-651701
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses two Coverity-reported defects in wolfSSH: a DEADCODE issue in algorithm list validation and a TOCTOU-style test defect in wolfsshd PID file verification.
Changes:
- Fixes unreachable
usableCount++logic for"none"by movingID_NONEhandling fully underWOLFSSH_ALLOW_NONE_CIPHERinCheckAlgoList(). - Updates
test_ConfigSavePID()to open PID files once andfstat()the opened handle (instead ofstat()+fopen()), ensuring asserted mode matches the file actually read.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/internal.c | Makes "none" acceptance/rejection compile-time consistent and removes dead/unreachable logic in CheckAlgoList(). |
| apps/wolfsshd/test/test_configuration.c | Reworks PID file read+mode assertions to avoid path-based TOCTOU in the test by using fopen() + fstat(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
philljj
approved these changes
Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Coverity flagged two new defects:
inside the WOLFSSH_ALLOW_NONE_CIPHER guard, so usableCount++ was
unreachable in the default build. The whole ID_NONE arm now lives under
the guard. Behavior is unchanged in both builds.
Scenarios 1 and 5 now fopen() once and fstat() that handle, so the mode
asserted is the mode of the file the PID was read from. A failed open is
a logged error rather than an indirect rd == 0.
The FIFO lstat() and the failPath existence test keep their path-based
checks: neither has a descriptor to stat, and mkdtemp() gives the test a
0700 directory.
Issues: CID-651701, CID-651702