From 5435230b4debdff793c682db1888730d91fd31de Mon Sep 17 00:00:00 2001 From: Xin LI Date: Sat, 16 Feb 2008 00:16:49 +0000 Subject: [PATCH] Allow underscore in domain names while resolving. While having underscore is a violation of RFC 1034 [STD 13], it is accepted by certain name servers as well as other popular operating systems' resolver library. Bugs are mine. Obtained from: ume MFC after: 2 weeks --- lib/libc/resolv/res_comp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/libc/resolv/res_comp.c b/lib/libc/resolv/res_comp.c index 35d62318584..a00755fbec0 100644 --- a/lib/libc/resolv/res_comp.c +++ b/lib/libc/resolv/res_comp.c @@ -140,6 +140,7 @@ dn_skipname(const u_char *ptr, const u_char *eom) { #define PERIOD 0x2e #define hyphenchar(c) ((c) == 0x2d) #define bslashchar(c) ((c) == 0x5c) +#define underscorechar(c) ((c) == 0x5f) #define periodchar(c) ((c) == PERIOD) #define asterchar(c) ((c) == 0x2a) #define alphachar(c) (((c) >= 0x41 && (c) <= 0x5a) \ @@ -147,7 +148,7 @@ dn_skipname(const u_char *ptr, const u_char *eom) { #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) || underscorechar(c)) #define domainchar(c) ((c) > 0x20 && (c) < 0x7f) int