Repository navigation
pw-inspector: restore "contains at least one" set logic - #1122
Merged
vanhauser-thc merged 1 commit intoNov 7, 2026
Merged
Conversation
Commit 28f073f (fix for vanhauser-thc#859) changed each set into an allow-list: every character in a password must belong to one of the given sets. This breaks the documented behavior, where -c MINSETS is "the minimum number of sets required": - With no sets given, nothing is output, so length-only filtering (pw-inspector -m 10) returns an empty list. - -l -u -n rejects passwords containing any other character, so the tool can no longer trim a wordlist to a policy such as "at least one lowercase, uppercase, and number". Restore the pre-9.5 logic: a set counts when the password contains at least one character from it, and other characters are allowed. Keep the later unsigned char buffer and bounded newline stripping. Output is byte-identical to v9.4 pw-inspector across length, single-set, multi-set, and -c combinations on a 1M-word list.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the change restoring minimum-set character matching.
No open issues 🎉
What changed in this PR
Restores pw-inspector’s pre-9.5 character-set matching behavior to align with the documented minimum-set policy rather than treating selected sets as an allow-list.
Changes:
- Counts each requested set when at least one matching character is present, while allowing other characters.
- Restores length-only filtering when no character sets are selected.
- Preserves the unsigned-character buffer and bounded newline/CR stripping.
| File | Description |
|---|---|
pw-inspector.c |
Restores presence-based character classification and minimum-set counting. |
Review effort: Balanced
Owner
|
thanks |
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.
Problem
Commit 28f073f (the fix for #859, first released in 9.5) changed each character set into an allow-list: every character in a password must belong to one of the given sets. The version string stayed at
v0.2, and this contradicts the documented-c MINSETSbehavior ("the minimum number of sets required"):pw-inspector -i wordlist.txt -m 10writes an empty file.-l -u -nrejects any password that contains a symbol (for example,Nell-y1998), so the tool can no longer trim a wordlist to a policy like "at least one lowercase, uppercase, and number".Fix
Restore the pre-9.5 logic: a set counts when the password contains at least one character from it, and other characters are allowed. Keep the later
unsigned charbuffer and bounded newline/CR stripping.Testing
Compared against v9.4
pw-inspectoron a 1M-word list. Output and return codes are byte-identical for:-m 10,-m 10 -l -u -n,-m 8 -l -u -n -p -c 3,-l,-s,-p,-m 6 -M 8 -u -n -c 1,-l -u -n -p -s,-l -u -n -p -s -c 2,-m 10 -c 1 -l -u -n -p -sAlso matches v9.4 on input containing non-ASCII and control bytes. No new compiler warnings under
-Wall -Wextra.Note
This reverts the #859 behavior, where
-lalone accepted only all-lowercase passwords. If that behavior is really what is wanted, it would be better to add an opt-in flag without changing the default (documented) behavior ofpw-inspector.