From: Alan T. DeKok Date: Sat, 18 Nov 2023 19:18:47 +0000 (-0500) Subject: add support for uncompressed dns labels X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9bfac6db259e1d8f41c321b4024eb9801730a105;p=thirdparty%2Ffreeradius-server.git add support for uncompressed dns labels --- diff --git a/src/protocols/dns/base.c b/src/protocols/dns/base.c index e615777a56b..06a748c689d 100644 --- a/src/protocols/dns/base.c +++ b/src/protocols/dns/base.c @@ -424,6 +424,7 @@ void fr_dns_global_free(void) static fr_table_num_ordered_t const subtype_table[] = { { L("dns_label"), FLAG_ENCODE_DNS_LABEL }, + { L("uncompressed"), FLAG_ENCODE_DNS_LABEL_UNCOMPRESSED }, }; diff --git a/src/protocols/dns/dns.h b/src/protocols/dns/dns.h index e4a2f45bbfa..2e4b952ae3a 100644 --- a/src/protocols/dns/dns.h +++ b/src/protocols/dns/dns.h @@ -76,6 +76,7 @@ typedef struct { enum { FLAG_ENCODE_NONE = 0, //!< no particular encoding for DNS strings FLAG_ENCODE_DNS_LABEL, //!< encode as DNS label + FLAG_ENCODE_DNS_LABEL_UNCOMPRESSED, //!< encode as uncompressed DNS label }; typedef struct { diff --git a/src/protocols/dns/encode.c b/src/protocols/dns/encode.c index ba782477a7a..6e88a094faa 100644 --- a/src/protocols/dns/encode.c +++ b/src/protocols/dns/encode.c @@ -149,13 +149,17 @@ static ssize_t encode_value(fr_dbuff_t *dbuff, /* * DNS labels get a special encoder. */ - if (!da->flags.extra && (da->flags.subtype == FLAG_ENCODE_DNS_LABEL)) { + if (!da->flags.extra) { fr_dbuff_marker_t last_byte, src; + fr_assert((da->flags.subtype == FLAG_ENCODE_DNS_LABEL) || + (da->flags.subtype == FLAG_ENCODE_DNS_LABEL_UNCOMPRESSED)); + fr_dbuff_marker(&last_byte, &work_dbuff); fr_dbuff_marker(&src, &work_dbuff); FR_PROTO_TRACE("encode DNS label %s", vp->vp_strvalue); - slen = fr_dns_label_from_value_box_dbuff(&work_dbuff, true, &vp->data, packet_ctx->lb); + slen = fr_dns_label_from_value_box_dbuff(&work_dbuff, (da->flags.subtype == FLAG_ENCODE_DNS_LABEL), + &vp->data, packet_ctx->lb); if (slen < 0) return slen; break; }