From e427d4b0e6223675cae8b17af81fdcf9fb7fc580 Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Tue, 4 Mar 2025 12:59:17 +0000 Subject: [PATCH] Default-off 0x20 encoding and provide --do-0x20-encode option. For now, this causes too many problems to default on. Hopefully this will change for future releases. --- src/dnsmasq.h | 3 ++- src/forward.c | 6 +++--- src/option.c | 3 +++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/dnsmasq.h b/src/dnsmasq.h index e858663..59d1dfa 100644 --- a/src/dnsmasq.h +++ b/src/dnsmasq.h @@ -280,7 +280,8 @@ struct event_desc { #define OPT_LOCALHOST_SERVICE 72 #define OPT_LOG_PROTO 73 #define OPT_NO_0x20 74 -#define OPT_LAST 75 +#define OPT_DO_0x20 75 +#define OPT_LAST 76 #define OPTION_BITS (sizeof(unsigned int)*8) #define OPTION_SIZE ( (OPT_LAST/OPTION_BITS)+((OPT_LAST%OPTION_BITS)!=0) ) diff --git a/src/forward.c b/src/forward.c index 0ad4f8a..8207a7e 100644 --- a/src/forward.c +++ b/src/forward.c @@ -391,7 +391,7 @@ static void forward_query(int udpfd, union mysockaddr *udpaddr, forward->new_id = get_id(); header->id = ntohs(forward->new_id); - forward->frec_src.encode_bitmap = option_bool(OPT_NO_0x20) ? 0 : rand32(); + forward->frec_src.encode_bitmap = (!option_bool(OPT_NO_0x20) && option_bool(OPT_DO_0x20)) ? rand32() : 0; forward->frec_src.encode_bigmap = NULL; p = (unsigned char *)(header+1); if (!extract_name(header, plen, &p, (char *)&forward->frec_src.encode_bitmap, EXTR_NAME_FLIP, 1)) @@ -3200,12 +3200,12 @@ static struct frec *lookup_frec(char *target, int class, int rrtype, int id, int struct dns_header *header; int compare_mode = EXTR_NAME_COMPARE; - /* Only compare case-sensitive when matching frec to a recieved answer, + /* Only compare case-sensitive when matching frec to a received answer, NOT when looking for a duplicated question. */ if (flags & FREC_ANSWER) { flags &= ~FREC_ANSWER; - if (!option_bool(OPT_NO_0x20)) + if (!option_bool(OPT_NO_0x20) && option_bool(OPT_DO_0x20)) compare_mode = EXTR_NAME_NOCASE; } diff --git a/src/option.c b/src/option.c index a87aeee..07d66ae 100644 --- a/src/option.c +++ b/src/option.c @@ -194,6 +194,7 @@ struct myoption { #define LOPT_DNSSEC_LIMITS 385 #define LOPT_PXE_OPT 386 #define LOPT_NO_ENCODE 387 +#define LOPT_DO_ENCODE 388 #ifdef HAVE_GETOPT_LONG static const struct option opts[] = @@ -249,6 +250,7 @@ static const struct myoption opts[] = { "no-negcache", 0, 0, 'N' }, { "no-round-robin", 0, 0, LOPT_NORR }, { "no-0x20-encode", 0, 0, LOPT_NO_ENCODE }, + { "do-0x20-encode", 0, 0, LOPT_DO_ENCODE }, { "cache-rr", 1, 0, LOPT_CACHE_RR }, { "addn-hosts", 1, 0, 'H' }, { "hostsdir", 1, 0, LOPT_HOST_INOTIFY }, @@ -594,6 +596,7 @@ static struct { { LOPT_QUIET_TFTP, OPT_QUIET_TFTP, NULL, gettext_noop("Do not log routine TFTP."), NULL }, { LOPT_NORR, OPT_NORR, NULL, gettext_noop("Suppress round-robin ordering of DNS records."), NULL }, { LOPT_NO_ENCODE, OPT_NO_0x20, NULL, gettext_noop("Suppress DNS bit 0x20 encoding."), NULL }, + { LOPT_DO_ENCODE, OPT_DO_0x20, NULL, gettext_noop("Enable DNS bit 0x20 encoding."), NULL }, { LOPT_NO_IDENT, OPT_NO_IDENT, NULL, gettext_noop("Do not add CHAOS TXT records."), NULL }, { LOPT_CACHE_RR, ARG_DUP, "", gettext_noop("Cache this DNS resource record type."), NULL }, { LOPT_MAX_PROCS, ARG_ONE, "", gettext_noop("Maximum number of concurrent tcp connections."), NULL },