From: Mark Andrews Date: Fri, 14 Nov 2025 01:59:29 +0000 (+1100) Subject: AMTRELAY type 0 presentation format handling was wrong X-Git-Tag: v9.21.16~42^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae484d450128658dd8fea9455c330095327c0e21;p=thirdparty%2Fbind9.git AMTRELAY type 0 presentation format handling was wrong RFC 8777 specifies a placeholder value of "." for the gateway field when the gateway type is 0 (no gateway). --- diff --git a/bin/tests/system/checkzone/zones/bad-cname-and-atmrelay.db b/bin/tests/system/checkzone/zones/bad-cname-and-amtrelay.db similarity index 95% rename from bin/tests/system/checkzone/zones/bad-cname-and-atmrelay.db rename to bin/tests/system/checkzone/zones/bad-cname-and-amtrelay.db index dc193af66b5..7c2aab24497 100644 --- a/bin/tests/system/checkzone/zones/bad-cname-and-atmrelay.db +++ b/bin/tests/system/checkzone/zones/bad-cname-and-amtrelay.db @@ -13,5 +13,5 @@ $TTL 600 @ SOA ns hostmaster 2011012708 3600 1200 604800 1200 NS ns ns A 192.0.2.1 -bad ATMRELAY 0 0 0 +bad AMTRELAY 0 0 0 . bad CNAME @ diff --git a/bin/tests/system/doth/example.axfr.good b/bin/tests/system/doth/example.axfr.good index d9e3cbf68ec..cf14b43d880 100644 --- a/bin/tests/system/doth/example.axfr.good +++ b/bin/tests/system/doth/example.axfr.good @@ -11,8 +11,8 @@ aaaa01.example. 3600 IN AAAA ::1 aaaa02.example. 3600 IN AAAA fd92:7065:b8e:ffff::5 afsdb01.example. 3600 IN AFSDB 0 hostname.example. afsdb02.example. 3600 IN AFSDB 65535 . -amtrelay01.example. 3600 IN AMTRELAY 0 0 0 -amtrelay02.example. 3600 IN AMTRELAY 0 1 0 +amtrelay01.example. 3600 IN AMTRELAY 0 0 0 . +amtrelay02.example. 3600 IN AMTRELAY 0 1 0 . amtrelay03.example. 3600 IN AMTRELAY 0 0 1 0.0.0.0 amtrelay04.example. 3600 IN AMTRELAY 0 0 2 :: amtrelay05.example. 3600 IN AMTRELAY 0 0 3 example.net. diff --git a/bin/tests/system/doth/example8.axfr.good b/bin/tests/system/doth/example8.axfr.good index 445653f394b..ba3ef872213 100644 --- a/bin/tests/system/doth/example8.axfr.good +++ b/bin/tests/system/doth/example8.axfr.good @@ -11,8 +11,8 @@ aaaa01.example8. 3600 IN AAAA ::1 aaaa02.example8. 3600 IN AAAA fd92:7065:b8e:ffff::5 afsdb01.example8. 3600 IN AFSDB 0 hostname.example8. afsdb02.example8. 3600 IN AFSDB 65535 . -amtrelay01.example8. 3600 IN AMTRELAY 0 0 0 -amtrelay02.example8. 3600 IN AMTRELAY 0 1 0 +amtrelay01.example8. 3600 IN AMTRELAY 0 0 0 . +amtrelay02.example8. 3600 IN AMTRELAY 0 1 0 . amtrelay03.example8. 3600 IN AMTRELAY 0 0 1 0.0.0.0 amtrelay04.example8. 3600 IN AMTRELAY 0 0 2 :: amtrelay05.example8. 3600 IN AMTRELAY 0 0 3 example.net. diff --git a/bin/tests/system/genzone.sh b/bin/tests/system/genzone.sh index 6762efd290f..70b4a9cf02e 100644 --- a/bin/tests/system/genzone.sh +++ b/bin/tests/system/genzone.sh @@ -487,8 +487,8 @@ doa01 DOA ( 1234567890 1234567890 1 "image/gif" doa02 DOA 0 1 2 "" aHR0cHM6Ly93d3cuaXNjLm9yZy8= ; type 260 -amtrelay01 AMTRELAY 0 0 0 -amtrelay02 AMTRELAY 0 1 0 +amtrelay01 AMTRELAY 0 0 0 . +amtrelay02 AMTRELAY 0 1 0 . amtrelay03 AMTRELAY 0 0 1 0.0.0.0 amtrelay04 AMTRELAY 0 0 2 :: amtrelay05 AMTRELAY 0 0 3 example.net. diff --git a/bin/tests/system/xfer/dig1.good b/bin/tests/system/xfer/dig1.good index dd0feed7538..06f9790d40d 100644 --- a/bin/tests/system/xfer/dig1.good +++ b/bin/tests/system/xfer/dig1.good @@ -12,8 +12,8 @@ aaaa01.example. 3600 IN AAAA ::1 aaaa02.example. 3600 IN AAAA fd92:7065:b8e:ffff::5 afsdb01.example. 3600 IN AFSDB 0 hostname.example. afsdb02.example. 3600 IN AFSDB 65535 . -amtrelay01.example. 3600 IN AMTRELAY 0 0 0 -amtrelay02.example. 3600 IN AMTRELAY 0 1 0 +amtrelay01.example. 3600 IN AMTRELAY 0 0 0 . +amtrelay02.example. 3600 IN AMTRELAY 0 1 0 . amtrelay03.example. 3600 IN AMTRELAY 0 0 1 0.0.0.0 amtrelay04.example. 3600 IN AMTRELAY 0 0 2 :: amtrelay05.example. 3600 IN AMTRELAY 0 0 3 example.net. diff --git a/bin/tests/system/xfer/dig2.good b/bin/tests/system/xfer/dig2.good index 880368c6039..1c1c60e4041 100644 --- a/bin/tests/system/xfer/dig2.good +++ b/bin/tests/system/xfer/dig2.good @@ -12,8 +12,8 @@ aaaa01.example. 3600 IN AAAA ::1 aaaa02.example. 3600 IN AAAA fd92:7065:b8e:ffff::5 afsdb01.example. 3600 IN AFSDB 0 hostname.example. afsdb02.example. 3600 IN AFSDB 65535 . -amtrelay01.example. 3600 IN AMTRELAY 0 0 0 -amtrelay02.example. 3600 IN AMTRELAY 0 1 0 +amtrelay01.example. 3600 IN AMTRELAY 0 0 0 . +amtrelay02.example. 3600 IN AMTRELAY 0 1 0 . amtrelay03.example. 3600 IN AMTRELAY 0 0 1 0.0.0.1 amtrelay04.example. 3600 IN AMTRELAY 0 0 2 :: amtrelay05.example. 3600 IN AMTRELAY 0 0 3 example.net. diff --git a/lib/dns/rdata/generic/amtrelay_260.c b/lib/dns/rdata/generic/amtrelay_260.c index c22a7d3fd62..0adec2ff84c 100644 --- a/lib/dns/rdata/generic/amtrelay_260.c +++ b/lib/dns/rdata/generic/amtrelay_260.c @@ -67,21 +67,22 @@ fromtext_amtrelay(ARGS_FROMTEXT) { RETERR(uint8_tobuffer(token.value.as_ulong | (discovery << 7), target)); gateway = token.value.as_ulong; - if (gateway == 0) { - return ISC_R_SUCCESS; - } - - if (gateway > 3) { - return ISC_R_NOTIMPLEMENTED; - } - /* - * Gateway. + * Gateway (must exist). */ RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, false)); + if (gateway > 3) { + return ISC_R_NOTIMPLEMENTED; + } + switch (gateway) { + case 0: + if (strcmp(DNS_AS_STR(token), ".") != 0) { + RETTOK(DNS_R_SYNTAX); + } + return ISC_R_SUCCESS; case 1: if (inet_pton(AF_INET, DNS_AS_STR(token), &addr) != 1) { RETTOK(DNS_R_BADDOTTEDQUAD); @@ -125,7 +126,6 @@ totext_amtrelay(ARGS_TOTEXT) { unsigned char precedence; unsigned char discovery; unsigned char gateway; - const char *space; UNUSED(tctx); @@ -151,9 +151,8 @@ totext_amtrelay(ARGS_TOTEXT) { gateway = uint8_fromregion(®ion); discovery = gateway >> 7; gateway &= 0x7f; - space = (gateway != 0U) ? " " : ""; isc_region_consume(®ion, 1); - snprintf(buf, sizeof(buf), "%u %u%s", discovery, gateway, space); + snprintf(buf, sizeof(buf), "%u %u ", discovery, gateway); RETERR(str_totext(buf, target)); /* @@ -161,7 +160,8 @@ totext_amtrelay(ARGS_TOTEXT) { */ switch (gateway) { case 0: - break; + return str_totext(".", target); + case 1: return inet_totext(AF_INET, tctx->flags, ®ion, target); diff --git a/tests/dns/rdata_test.c b/tests/dns/rdata_test.c index 2141596854b..2ef35f1b905 100644 --- a/tests/dns/rdata_test.c +++ b/tests/dns/rdata_test.c @@ -1029,11 +1029,13 @@ ISC_RUN_TEST_IMPL(atma) { ISC_RUN_TEST_IMPL(amtrelay) { text_ok_t text_ok[] = { TEXT_INVALID(""), TEXT_INVALID("0"), TEXT_INVALID("0 0"), + TEXT_INVALID("0 0 0"), /* gateway type 0 */ - TEXT_VALID("0 0 0"), TEXT_VALID("0 1 0"), - TEXT_INVALID("0 2 0"), /* discovery out of range */ - TEXT_VALID("255 1 0"), /* max precedence */ - TEXT_INVALID("256 1 0"), /* precedence out of range */ + TEXT_INVALID("0 0 0 x"), /* bad placeholder */ + TEXT_VALID("0 0 0 ."), TEXT_VALID("0 1 0 ."), + TEXT_INVALID("0 2 0 ."), /* discovery out of range */ + TEXT_VALID("255 1 0 ."), /* max precedence */ + TEXT_INVALID("256 1 0 ."), /* precedence out of range */ /* IPv4 gateway */ TEXT_INVALID("0 0 1"), /* no address */