Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

misc/50299: Resolver rejects hostnames with underscores

0 views
Skip to first unread message

Marius Strom

unread,
Mar 25, 2003, 5:40:25 PM3/25/03
to FreeBSD-gn...@freebsd.org

>Number: 50299
>Category: misc
>Synopsis: Resolver rejects hostnames with underscores
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Tue Mar 25 14:40:12 PST 2003
>Closed-Date:
>Last-Modified:
>Originator: Marius Strom
>Release: FreeBSD 4.7-STABLE i386
>Organization:
marius dot org
>Environment:
System: FreeBSD sashimi.marius.org 4.7-STABLE FreeBSD 4.7-STABLE #2: Mon Nov 4 21:52:24 CST 2002 ro...@sashimi.marius.org:/usr/obj/usr/src/sys/SASHIMI.MARIUS.ORG-AMD i386


>Description:
FreeBSD's resolver will reject hostnames/domains that have underscores in
them. While RFC952 forbids these, RFC952 does not cover DNS. RFC2181
does, and lists no such restriction. Other OS (Microsoft, Mac OS X,
Linux, etc.) do not have this restriction.

>How-To-Repeat:
ping host_name_with_underscore.domain.tld
(subsitute ping for any tool using the FreeBSD resolver)
>Fix:
Apply this patch:

--- lib/libc/net/res_comp.c.orig Tue Mar 25 16:23:06 2003
+++ lib/libc/net/res_comp.c Tue Mar 25 16:24:21 2003
@@ -144,13 +144,14 @@
#define hyphenchar(c) ((c) == 0x2d)
#define bslashchar(c) ((c) == 0x5c)
#define periodchar(c) ((c) == PERIOD)
+#define uscorechar(c) ((c) == 0x5f)
#define asterchar(c) ((c) == 0x2a)
#define alphachar(c) (((c) >= 0x41 && (c) <= 0x5a) \
|| ((c) >= 0x61 && (c) <= 0x7a))
#define digitchar(c) ((c) >= 0x30 && (c) <= 0x39)

#define borderchar(c) (alphachar(c) || digitchar(c))
-#define middlechar(c) (borderchar(c) || hyphenchar(c))
+#define middlechar(c) (borderchar(c) || hyphenchar(c) || uscorechar(c))
#define domainchar(c) ((c) > 0x20 && (c) < 0x7f)

int


>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majo...@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message

David J Duchscher

unread,
Mar 26, 2003, 2:03:59 AM3/26/03
to freebs...@freebsd.org
The following reply was made to PR misc/50299; it has been noted by GNATS.

From: David J Duchscher <da...@nostrum.com>
To: freebsd-gn...@FreeBSD.org, mar...@marius.org
Cc:
Subject: Re: misc/50299: Resolver rejects hostnames with underscores
Date: Wed, 26 Mar 2003 00:42:05 -0600

Here is a patch that makes this behavior optional via the options
directive in the resolv.conf file.

DaveD

diff -ru ../src.orig/include/resolv.h ./include/resolv.h
--- ../src.orig/include/resolv.h Tue Mar 25 20:41:46 2003
+++ ./include/resolv.h Wed Mar 26 00:18:08 2003
@@ -150,6 +150,7 @@
#define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */
#define RES_USE_INET6 0x00002000 /* use/map IPv6 in gethostbyname() */
#define RES_NOTLDQUERY 0x00004000 /* Don't query TLD names */
+#define RES_ALLOWUSCORE 0x00008000 /* Alllow underscore in hostname */
/* KAME extensions: use higher bit to avoid conflict with ISC use */
#define RES_USE_EDNS0 0x40000000 /* use EDNS0 */

diff -ru ../src.orig/lib/libc/net/res_comp.c ./lib/libc/net/res_comp.c
--- ../src.orig/lib/libc/net/res_comp.c Tue Mar 25 20:39:27 2003
+++ ./lib/libc/net/res_comp.c Wed Mar 26 00:17:33 2003
@@ -142,6 +142,7 @@
*/
#define PERIOD 0x2e


#define hyphenchar(c) ((c) == 0x2d)

+#define uscorechar(c) ((c) == 0x5f)
#define bslashchar(c) ((c) == 0x5c)
#define periodchar(c) ((c) == PERIOD)
#define asterchar(c) ((c) == 0x2a)

@@ -171,8 +172,13 @@
if (!borderchar(ch))
return (0);
} else {
- if (!middlechar(ch))
- return (0);
+ if (_res.options & RES_ALLOWUSCORE) {
+ if (!middlechar(ch) && !uscorechar(ch))
+ return(0);
+ } else {
+ if (!middlechar(ch))
+ return (0);
+ }
}
ppch = pch, pch = ch, ch = nch;
}
diff -ru ../src.orig/lib/libc/net/res_init.c ./lib/libc/net/res_init.c
--- ../src.orig/lib/libc/net/res_init.c Tue Mar 25 20:39:27 2003
+++ ./lib/libc/net/res_init.c Wed Mar 26 00:17:52 2003
@@ -539,6 +539,8 @@
_res.options |= RES_INSECURE2;
} else if (!strncmp(cp, "no_tld_query", sizeof("no_tld_query") - 1))
{
_res.options |= RES_NOTLDQUERY;
+ } else if (!strncmp(cp, "allow_underscore",
sizeof("allow_underscore") - 1)) {
+ _res.options |= RES_ALLOWUSCORE;
} else if (!strncmp(cp, "edns0", sizeof("edns0") - 1)) {
_res.options |= RES_USE_EDNS0;
} else {
diff -ru ../src.orig/share/man/man5/resolver.5
./share/man/man5/resolver.5
--- ../src.orig/share/man/man5/resolver.5 Tue Mar 25 20:42:08 2003
+++ ./share/man/man5/resolver.5 Wed Mar 26 00:30:51 2003
@@ -125,7 +125,7 @@
.Sy option
is one of the following:
.Pp
-.Bl -tag -width no_tld_query
+.Bl -tag -width allow_underscore
.It Sy debug
sets
.Dv RES_DEBUG
@@ -154,6 +154,11 @@
and
.Sy search
rules with the given name.
+.It Sy allow_underscore
+tells the resolver to allow underscores in hostsnames. Normally the
+resolver will filter out hostnames that do not conform to RFC 952.
+This extends the allowed set of characters in the middle of the
+hostname to include the underscore character.
.El
.Pp
Options may also be specified as a space or tab separated list using
the

_______________________________________________
freebs...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs...@freebsd.org"

Jacques Vidrine

unread,
Mar 26, 2003, 10:19:47 AM3/26/03
to mar...@marius.org, nec...@freebsd.org, freebs...@freebsd.org
Synopsis: Resolver rejects hostnames with underscores

State-Changed-From-To: open->closed
State-Changed-By: nectar
State-Changed-When: Wed Mar 26 07:15:14 PST 2003
State-Changed-Why:
The current behavior is correct. Callers of res_hnok
(e.g. getaddrinfo, gethostbyname) must reject hostnames


that do not conform to RFC 952.

http://www.freebsd.org/cgi/query-pr.cgi?pr=50299

0 new messages