From 3773d35eb98e22b5edab4d82fb72bdf86ff80494 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Mon, 27 Jul 2009 19:19:29 +0200 Subject: [PATCH] Make the DNS resolver accept domain names with an underscore. More precisely, this accepts domain labels with an underscore in the middle (i.e. not at the start or the end of the label). This is needed to perform complex CNAME chain resolution in certain VPN networks. --- libc/netbsd/resolv/res_comp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libc/netbsd/resolv/res_comp.c b/libc/netbsd/resolv/res_comp.c index 6991e8b40..77b81b4ae 100644 --- a/libc/netbsd/resolv/res_comp.c +++ b/libc/netbsd/resolv/res_comp.c @@ -147,6 +147,12 @@ dn_skipname(const u_char *ptr, const u_char *eom) { * tell us anything about network-format data. The rest of the BIND system * is not careful about this, but for some reason, we're doing it right here. */ + +/* BIONIC: We also accept underscores in the middle of labels. + * This extension is needed to make resolution on some VPN networks + * work properly. + */ + #define PERIOD 0x2e #define hyphenchar(c) ((c) == 0x2d) #define bslashchar(c) ((c) == 0x5c) @@ -155,9 +161,10 @@ dn_skipname(const u_char *ptr, const u_char *eom) { #define alphachar(c) (((c) >= 0x41 && (c) <= 0x5a) \ || ((c) >= 0x61 && (c) <= 0x7a)) #define digitchar(c) ((c) >= 0x30 && (c) <= 0x39) +#define underscorechar(c) ((c) == 0x5f) #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 -- 2.11.0