1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-24 21:34:08 +03:00

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.

(cherry picked from commit 84f788d669)
This commit is contained in:
Evgeny Vereshchagin 2022-11-26 12:02:46 +00:00 committed by Zbigniew Jędrzejewski-Szmek
parent d59009dc1d
commit 44984e15bb

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;