From: Evan Hunt Date: Sat, 14 Sep 2019 17:23:24 +0000 (-0700) Subject: always print a colon after EDNS option names in YAML output X-Git-Tag: v9.15.6~69^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed1b328186cd06cd4845675d7c1f2656c912545a;p=thirdparty%2Fbind9.git always print a colon after EDNS option names in YAML output previously, if the option was empty, then it was printed without a colon, which could not be parsed as YAML. adding a colon in all cases addresses this problem. --- diff --git a/lib/dns/message.c b/lib/dns/message.c index 4c767cdbb52..cb5469693b1 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -3416,7 +3416,7 @@ render_ecs(isc_buffer_t *ecsbuf, isc_buffer_t *target) { return (DNS_R_OPTERR); } - ADD_STRING(target, ": "); + ADD_STRING(target, " "); ADD_STRING(target, addr_text); snprintf(addr_text, sizeof(addr_text), "/%d/%d", addrlen, scopelen); ADD_STRING(target, addr_text); @@ -3551,8 +3551,8 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, if (optcode == DNS_OPT_LLQ) { INDENT(style); + ADD_STRING(target, "LLQ:"); if (optlen == 18U) { - ADD_STRING(target, "LLQ: "); result = render_llq(&optbuf, target); if (result != ISC_R_SUCCESS) { goto cleanup; @@ -3560,24 +3560,24 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, ADD_STRING(target, "\n"); continue; } - ADD_STRING(target, "LLQ"); } else if (optcode == DNS_OPT_NSID) { INDENT(style); - ADD_STRING(target, "NSID"); + ADD_STRING(target, "NSID:"); } else if (optcode == DNS_OPT_COOKIE) { INDENT(style); - ADD_STRING(target, "COOKIE"); + ADD_STRING(target, "COOKIE:"); } else if (optcode == DNS_OPT_CLIENT_SUBNET) { isc_buffer_t ecsbuf; INDENT(style); - ADD_STRING(target, "CLIENT-SUBNET"); + ADD_STRING(target, "CLIENT-SUBNET:"); isc_buffer_init(&ecsbuf, isc_buffer_current(&optbuf), optlen); isc_buffer_add(&ecsbuf, optlen); result = render_ecs(&ecsbuf, target); - if (result == ISC_R_NOSPACE) + if (result == ISC_R_NOSPACE) { goto cleanup; + } if (result == ISC_R_SUCCESS) { isc_buffer_forward(&optbuf, optlen); ADD_STRING(target, "\n"); @@ -3585,40 +3585,36 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, } ADD_STRING(target, "\n"); } else if (optcode == DNS_OPT_EXPIRE) { + INDENT(style); + ADD_STRING(target, "EXPIRE:"); if (optlen == 4) { uint32_t secs; secs = isc_buffer_getuint32(&optbuf); - INDENT(style); - ADD_STRING(target, "EXPIRE: "); - snprintf(buf, sizeof(buf), "%u", secs); + snprintf(buf, sizeof(buf), " %u", secs); ADD_STRING(target, buf); ADD_STRING(target, " ("); - result = dns_ttl_totext(secs, - true, - true, - target); + result = dns_ttl_totext(secs, true, + true, target); if (result != ISC_R_SUCCESS) goto cleanup; ADD_STRING(target, ")\n"); continue; } - INDENT(style); - ADD_STRING(target, "EXPIRE"); } else if (optcode == DNS_OPT_PAD) { INDENT(style); - ADD_STRING(target, "PAD"); + ADD_STRING(target, "PAD:"); } else if (optcode == DNS_OPT_KEY_TAG) { INDENT(style); - ADD_STRING(target, "KEY-TAG"); + ADD_STRING(target, "KEY-TAG:"); if (optlen > 0U && (optlen % 2U) == 0U) { - const char *sep = ": "; + const char *sep = ""; uint16_t id; while (optlen > 0U) { id = isc_buffer_getuint16(&optbuf); - snprintf(buf, sizeof(buf), "%s%u", + snprintf(buf, sizeof(buf), "%s %u", sep, id); ADD_STRING(target, buf); - sep = ", "; + sep = ","; optlen -= 2; } ADD_STRING(target, "\n"); @@ -3627,11 +3623,10 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, } else if (optcode == DNS_OPT_CLIENT_TAG) { uint16_t id; INDENT(style); - ADD_STRING(target, "CLIENT-TAG"); + ADD_STRING(target, "CLIENT-TAG:"); if (optlen == 2U) { id = isc_buffer_getuint16(&optbuf); - snprintf(buf, sizeof(buf), ": %u\n", - id); + snprintf(buf, sizeof(buf), " %u\n", id); ADD_STRING(target, buf); optlen -= 2; POST(optlen); @@ -3640,11 +3635,10 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, } else if (optcode == DNS_OPT_SERVER_TAG) { uint16_t id; INDENT(style); - ADD_STRING(target, "SERVER-TAG"); + ADD_STRING(target, "SERVER-TAG:"); if (optlen == 2U) { id = isc_buffer_getuint16(&optbuf); - snprintf(buf, sizeof(buf), ": %u\n", - id); + snprintf(buf, sizeof(buf), " %u\n", id); ADD_STRING(target, buf); optlen -= 2; POST(optlen); @@ -3652,15 +3646,15 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, } } else { INDENT(style); - ADD_STRING(target, "OPT: "); - snprintf(buf, sizeof(buf), "%u", optcode); + ADD_STRING(target, "OPT="); + snprintf(buf, sizeof(buf), "%u:", optcode); ADD_STRING(target, buf); - ADD_STRING(target, "\n"); } if (optlen != 0) { int i; - ADD_STRING(target, ": "); + + ADD_STRING(target, " "); optdata = isc_buffer_current(&optbuf); for (i = 0; i < optlen; i++) {