Skip to content

Commit

Permalink
fixed off by one error in partial name check. Added test for same.
Browse files Browse the repository at this point in the history
  • Loading branch information
dghgit committed Apr 5, 2018
1 parent 96dbf09 commit 8672f1a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public static boolean isValidNameMatch(String name, String dnsName, Set<String>

if (wildIndex > 0)
{
if (loweredName.startsWith(dnsName.substring(0, wildIndex - 1)) && loweredName.endsWith(end))
if (loweredName.startsWith(dnsName.substring(0, wildIndex)) && loweredName.endsWith(end))
{
return loweredName.substring(wildIndex, loweredName.length() - end.length()).indexOf('.') < 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public void testWildcardMatcher()
{"Invalid 13", "foo.example.com","*.example.com",true},
{"Invalid 14", "bar.foo.example.com", "*.example.com", false},
{"Invalid 15", "example.com", "*.example.com", false},
{"Invalid 16", "foobaz.example.com","b*z.example.com",false},
{"Invalid 17", "foobaz.example.com","ob*z.example.com",false},
{ "Valid", "foobaz.example.com","foob*z.example.com",true}
};

for (Object[] j : v)
Expand Down

0 comments on commit 8672f1a

Please sign in to comment.