From: Mark Andrews Date: Tue, 29 Oct 2024 05:01:58 +0000 (+1100) Subject: Change the EDNS KEY-TAG YAML output format X-Git-Tag: v9.21.8~16^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27e8732c1726aebc43d41e39b115d0c7eda5bb77;p=thirdparty%2Fbind9.git Change the EDNS KEY-TAG YAML output format When using YAML, print the EDNS KEY-TAG as an array of integers for easier machine parsing. Check the validity of the YAML output. --- diff --git a/bin/tests/system/digdelv/tests.sh b/bin/tests/system/digdelv/tests.sh index 65bf8f50f89..249c9989d48 100644 --- a/bin/tests/system/digdelv/tests.sh +++ b/bin/tests/system/digdelv/tests.sh @@ -645,6 +645,18 @@ if [ -x "$DIG" ]; then if [ $ret -ne 0 ]; then echo_i "failed"; fi status=$((status + ret)) + if [ $HAS_PYYAML -ne 0 ]; then + n=$((n + 1)) + ret=0 + echo_i "check that dig processes +ednsopt=key-tag: +yaml ($n)" + dig_with_opts @10.53.0.3 +yaml +ednsopt=key-tag:00010002 a.example +qr >dig.out.test$n 2>&1 || ret=1 + $PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS KEY-TAG >yamlget.out.test$n 2>&1 || ret=1 + read -r value and FORMERR is returned ($n)" ret=0 diff --git a/lib/dns/message.c b/lib/dns/message.c index 0f046f78bea..8673dc71211 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -3809,7 +3809,7 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section, break; case DNS_OPT_KEY_TAG: if (optlen > 0U && (optlen % 2U) == 0U) { - const char *sep = ""; + const char *sep = " ["; while (optlen > 0U) { uint16_t id = isc_buffer_getuint16( @@ -3820,7 +3820,7 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section, sep = ","; optlen -= 2; } - ADD_STRING(target, "\n"); + ADD_STRING(target, " ]\n"); continue; } break;