Skip to content

Commit b5a3d96

Browse files
committed
Asterisks should be allowed in host validation as CNAMEs may reference wildcard domains
CloudFlare appears to use this logic in CNAMEs as per nodejs/node#42171 Fixes: #457 Fix By: Brad House (@bradh352)
1 parent 320b99b commit b5a3d96

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/lib/ares_expand_name.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,16 @@ static int ares__isprint(int ch)
6464
* - underscores which are used in SRV records.
6565
* - Forward slashes such as are used for classless in-addr.arpa
6666
* delegation (CNAMEs)
67+
* - Asterisks may be used for wildcard domains in CNAMEs as seen in the
68+
* real world.
6769
* While RFC 2181 section 11 does state not to do validation,
6870
* that applies to servers, not clients. Vulnerabilities have been
6971
* reported when this validation is not performed. Security is more
7072
* important than edge-case compatibility (which is probably invalid
7173
* anyhow). */
7274
static int is_hostnamech(int ch)
7375
{
74-
/* [A-Za-z0-9-._/]
76+
/* [A-Za-z0-9-*._/]
7577
* Don't use isalnum() as it is locale-specific
7678
*/
7779
if (ch >= 'A' && ch <= 'Z')
@@ -80,7 +82,7 @@ static int is_hostnamech(int ch)
8082
return 1;
8183
if (ch >= '0' && ch <= '9')
8284
return 1;
83-
if (ch == '-' || ch == '.' || ch == '_' || ch == '/')
85+
if (ch == '-' || ch == '.' || ch == '_' || ch == '/' || ch == '*')
8486
return 1;
8587

8688
return 0;

0 commit comments

Comments
 (0)