Fix the skip guard for Mac environment#1040
Open
yosuke-wolfssl wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a macOS/Darwin-specific false failure in the wolfsshd test suite by tightening the skip guard in test_CheckPasswordHashUnix() so the test only runs when crypt(3) actually produces a $6$ (SHA-512 modular-crypt) hash rather than silently falling back to legacy DES.
Changes:
- Add a runtime guard that verifies
crypt()honored the$6$request by checking the returned hash prefix begins with"$6$". - Improve the skip message and add an explanatory comment documenting the Darwin/BSD DES-fallback behavior and why it breaks the negative-path test.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1040
Scan targets checked: wolfssh-bugs, wolfssh-src
No new issues found in the changed files. ✅
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.
Fix
test_CheckPasswordHashUnixfalse-fail on macOS/DarwinSummary
test_CheckPasswordHashUnixinapps/wolfsshd/test/test_configuration.cfalse-fails on macOS (and some BSDs) because the platform
crypt(3)does notimplement the
$6$(SHA-512) modular-crypt format. This is a test-harness bug,not a defect in
CheckPasswordHashUnix()itself.Root cause
The test builds a stored hash with a SHA-512 modular-crypt salt:
macOS/Darwin libc
crypt(3)only supports legacy DES. Given a$6$…salt itsilently falls back to DES, using just the first 2 characters as the salt and
truncating the password to 8 bytes. Both test passwords share their first
8 bytes (
wolfssh-), so DES produces an identical hash for the "correct" and"wrong" passwords. The negative path ("wrong password is rejected") then
genuinely matches,
CheckPasswordHashUnix()correctly returnsWSSHD_AUTH_SUCCESS, and the test fails withret=-1001(binary exits 23).The existing skip guard only caught the
NULL/*/ empty crypt-failureconventions. The DES fallback returns a valid-looking 13-char hash, so the
guard never tripped and the test proceeded with degenerate coverage.
Fix
Tighten the skip guard to verify
crypt()actually honored the$6$requestbefore trusting the negative path. A real SHA-512 hash begins with
$6$<salt>$;the DES fallback begins
$6l…(no second$), so aWSTRNCMP(hash, "$6$", 3)prefix check cleanly distinguishes them.
On glibc-based Linux the
$6$hash is produced as expected and the test runsnormally; only platforms whose
crypt(3)lacks$6$support now skip insteadof false-failing.
Testing
test_configurationfull suite: PASS (exit 0) on macOS — the passwordhash case now logs
crypt() did not honor $6$ SHA-512, skipping.