From 66eaf6bb738cd146662f6198f4d720dfb06bb9da Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Fri, 26 Aug 2022 17:58:55 -0700 Subject: [PATCH] quote addresses in YAML output YAML strings should be quoted if they contain colon characters. Since IPv6 addresses do, we now quote the query_address and response_address strings in all YAML output. --- bin/dig/dig.c | 4 ++-- bin/tools/dnstap-read.c | 4 ++-- bin/tools/mdig.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/dig/dig.c b/bin/dig/dig.c index a416f3fd47..49143e581b 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -784,7 +784,7 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf, dns_message_t *msg, strlcat(sockstr, "0", sizeof(sockstr)); } - printf(" response_address: %s\n", sockstr); + printf(" response_address: \"%s\"\n", sockstr); printf(" response_port: %u\n", sport); } @@ -801,7 +801,7 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf, dns_message_t *msg, strlcat(sockstr, "0", sizeof(sockstr)); } - printf(" query_address: %s\n", sockstr); + printf(" query_address: \"%s\"\n", sockstr); printf(" query_port: %u\n", sport); } diff --git a/bin/tools/dnstap-read.c b/bin/tools/dnstap-read.c index 78b95a76fb..933e76ad04 100644 --- a/bin/tools/dnstap-read.c +++ b/bin/tools/dnstap-read.c @@ -266,7 +266,7 @@ print_yaml(dns_dtdata_t *dt) { (void)inet_ntop(ip->len == 4 ? AF_INET : AF_INET6, ip->data, buf, sizeof(buf)); - printf(" query_address: %s\n", buf); + printf(" query_address: \"%s\"\n", buf); } if (m->has_response_address) { @@ -275,7 +275,7 @@ print_yaml(dns_dtdata_t *dt) { (void)inet_ntop(ip->len == 4 ? AF_INET : AF_INET6, ip->data, buf, sizeof(buf)); - printf(" response_address: %s\n", buf); + printf(" response_address: \"%s\"\n", buf); } if (m->has_query_port) { diff --git a/bin/tools/mdig.c b/bin/tools/mdig.c index 9e81459919..1d28ea979f 100644 --- a/bin/tools/mdig.c +++ b/bin/tools/mdig.c @@ -331,7 +331,7 @@ recvresponse(isc_task_t *task, isc_event_t *event) { if (hash != NULL) { *hash = '\0'; } - printf(" response_address: %s\n", sockstr); + printf(" response_address: \"%s\"\n", sockstr); printf(" response_port: %u\n", sport); } @@ -342,7 +342,7 @@ recvresponse(isc_task_t *task, isc_event_t *event) { if (hash != NULL) { *hash = '\0'; } - printf(" query_address: %s\n", sockstr); + printf(" query_address: \"%s\"\n", sockstr); printf(" query_port: %u\n", sport); }