Commit a8baf79e authored by Evan Hunt's avatar Evan Hunt
Browse files

append "0" to IPv6 addresses ending in "::" when printing YAML

such addresses broke some YAML parsers.
parent 5d3a7aad
Pipeline #45278 failed with stages
in 38 minutes and 33 seconds
5447. [bug] IPv6 addresses ending in "::" could break YAML
parsing. A "0" is now appended to such addresses
in YAML output from dig, mdig, delv, and dnstap-read.
[GL #1952]
5446. [bug] The validator could fail to accept a properly signed
RRset if an unsupported algorithm appeared earlier in
the DNSKEY RRset than a supported algorithm. It could
......
......@@ -28,6 +28,8 @@ b A 10.0.0.2
b AAAA fd92:7065:b8e:ffff::2
c A 10.0.0.3
c AAAA fd92:7065:b8e:ffff::3
d A 10.0.0.0
d AAAA fd92:7065:b8e:ffff::
xn--caf-dma A 10.1.2.3
......
......@@ -907,6 +907,16 @@ if [ -x "$DIG" ] ; then
[ "$value" = "ns2.example. IN ANY" ] || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "check dig +yaml output of an IPv6 address ending in zeroes ($n)"
ret=0
dig_with_opts +qr +yaml @10.53.0.3 aaaa d.example > dig.out.test$n 2>&1 || ret=1
$PYTHON yamlget.py dig.out.test$n 1 message response_message_data ANSWER_SECTION 0 > yamlget.out.test$n 2>&1 || ret=1
read -r value < yamlget.out.test$n
[ "$value" = "d.example. 300 IN AAAA fd92:7065:b8e:ffff::0" ] || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
fi
n=$((n+1))
......
......@@ -151,7 +151,7 @@ static isc_result_t
str_totext(const char *source, isc_buffer_t *target);
static isc_result_t
inet_totext(int af, isc_region_t *src, isc_buffer_t *target);
inet_totext(int af, uint32_t flags, isc_region_t *src, isc_buffer_t *target);
static bool
buffer_empty(isc_buffer_t *source);
......@@ -1754,7 +1754,7 @@ str_totext(const char *source, isc_buffer_t *target) {
}
static isc_result_t
inet_totext(int af, isc_region_t *src, isc_buffer_t *target) {
inet_totext(int af, uint32_t flags, isc_region_t *src, isc_buffer_t *target) {
char tmpbuf[64];
/* Note - inet_ntop doesn't do size checking on its input. */
......@@ -1765,6 +1765,22 @@ inet_totext(int af, isc_region_t *src, isc_buffer_t *target) {
return (ISC_R_NOSPACE);
}
isc_buffer_putstr(target, tmpbuf);
/*
* An IPv6 address ending in "::" breaks YAML
* parsing, so append 0 in that case.
*/
if (af == AF_INET6 && (flags & DNS_STYLEFLAG_YAML) != 0) {
isc_textregion_t tr;
isc_buffer_usedregion(target, (isc_region_t *)&tr);
if (tr.base[tr.length - 1] == ':') {
if (isc_buffer_availablelength(target) == 0) {
return (ISC_R_NOSPACE);
}
isc_buffer_putmem(target, "0", 1);
}
}
return (ISC_R_SUCCESS);
}
......
......@@ -165,10 +165,10 @@ totext_amtrelay(ARGS_TOTEXT) {
case 0:
break;
case 1:
return (inet_totext(AF_INET, &region, target));
return (inet_totext(AF_INET, tctx->flags, &region, target));
case 2:
return (inet_totext(AF_INET6, &region, target));
return (inet_totext(AF_INET6, tctx->flags, &region, target));
case 3:
dns_name_init(&name, NULL);
......
......@@ -174,12 +174,12 @@ totext_ipseckey(ARGS_TOTEXT) {
break;
case 1:
RETERR(inet_totext(AF_INET, &region, target));
RETERR(inet_totext(AF_INET, tctx->flags, &region, target));
isc_region_consume(&region, 4);
break;
case 2:
RETERR(inet_totext(AF_INET6, &region, target));
RETERR(inet_totext(AF_INET6, tctx->flags, &region, target));
isc_region_consume(&region, 16);
break;
......
......@@ -73,7 +73,7 @@ totext_l32(ARGS_TOTEXT) {
RETERR(str_totext(" ", target));
return (inet_totext(AF_INET, &region, target));
return (inet_totext(AF_INET, tctx->flags, &region, target));
}
static inline isc_result_t
......
......@@ -57,7 +57,7 @@ totext_hs_a(ARGS_TOTEXT) {
UNUSED(tctx);
dns_rdata_toregion(rdata, &region);
return (inet_totext(AF_INET, &region, target));
return (inet_totext(AF_INET, tctx->flags, &region, target));
}
static inline isc_result_t
......
......@@ -126,7 +126,7 @@ totext_in_a6(ARGS_TOTEXT) {
addr[octets] &= mask;
ar.base = addr;
ar.length = sizeof(addr);
RETERR(inet_totext(AF_INET6, &ar, target));
RETERR(inet_totext(AF_INET6, tctx->flags, &ar, target));
isc_region_consume(&sr, 16 - octets);
}
......
......@@ -59,7 +59,7 @@ totext_in_a(ARGS_TOTEXT) {
UNUSED(tctx);
dns_rdata_toregion(rdata, &region);
return (inet_totext(AF_INET, &region, target));
return (inet_totext(AF_INET, tctx->flags, &region, target));
}
static inline isc_result_t
......
......@@ -75,7 +75,7 @@ totext_in_aaaa(ARGS_TOTEXT) {
return (str_totext(buf, target));
}
dns_rdata_toregion(rdata, &region);
return (inet_totext(AF_INET6, &region, target));
return (inet_totext(AF_INET6, tctx->flags, &region, target));
}
static inline isc_result_t
......
......@@ -154,7 +154,7 @@ totext_in_apl(ARGS_TOTEXT) {
INSIST(prefix <= 32);
memset(buf, 0, sizeof(buf));
memmove(buf, sr.base, len);
RETERR(inet_totext(AF_INET, &ir, target));
RETERR(inet_totext(AF_INET, tctx->flags, &ir, target));
break;
case 2:
......@@ -162,7 +162,7 @@ totext_in_apl(ARGS_TOTEXT) {
INSIST(prefix <= 128);
memset(buf, 0, sizeof(buf));
memmove(buf, sr.base, len);
RETERR(inet_totext(AF_INET6, &ir, target));
RETERR(inet_totext(AF_INET6, tctx->flags, &ir, target));
break;
default:
......
......@@ -218,7 +218,7 @@ totext_in_wks(ARGS_TOTEXT) {
REQUIRE(rdata->length >= 5);
dns_rdata_toregion(rdata, &sr);
RETERR(inet_totext(AF_INET, &sr, target));
RETERR(inet_totext(AF_INET, tctx->flags, &sr, target));
isc_region_consume(&sr, 4);
proto = uint8_fromregion(&sr);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment