resolve: format zero-length RDATA according to rfc3597

If the RDATA is of zero length, the text representation contains only
the \# token and the single zero representing the length.
This commit is contained in:
Evgeny Vereshchagin
2022-11-26 12:20:21 +00:00
parent 49f936cd0a
commit 84f788d669
+8 -5
View File
@@ -1137,12 +1137,15 @@ const char *dns_resource_record_to_string(DnsResourceRecord *rr) {
break;
default:
t = hexmem(rr->generic.data, rr->generic.data_size);
if (!t)
return NULL;
/* Format as documented in RFC 3597, Section 5 */
r = asprintf(&s, "%s \\# %zu %s", k, rr->generic.data_size, t);
if (rr->generic.data_size == 0)
r = asprintf(&s, "%s \\# 0", k);
else {
t = hexmem(rr->generic.data, rr->generic.data_size);
if (!t)
return NULL;
r = asprintf(&s, "%s \\# %zu %s", k, rr->generic.data_size, t);
}
if (r < 0)
return NULL;
break;