resolved: improve printing of unknown RRs

This implements the recommendations from RFC3597.
This commit is contained in:
Tom Gundersen 2015-07-14 04:32:29 +02:00
parent abf126a355
commit d23a27a964
1 changed files with 5 additions and 5 deletions

View File

@ -171,19 +171,19 @@ const struct hash_ops dns_resource_key_hash_ops = {
};
int dns_resource_key_to_string(const DnsResourceKey *key, char **ret) {
char cbuf[DECIMAL_STR_MAX(uint16_t)], tbuf[DECIMAL_STR_MAX(uint16_t)];
char cbuf[strlen("CLASS") + DECIMAL_STR_MAX(uint16_t)], tbuf[strlen("TYPE") + DECIMAL_STR_MAX(uint16_t)];
const char *c, *t;
char *s;
c = dns_class_to_string(key->class);
if (!c) {
sprintf(cbuf, "%i", key->class);
sprintf(cbuf, "CLASS%u", key->class);
c = cbuf;
}
t = dns_type_to_string(key->type);
if (!t){
sprintf(tbuf, "%i", key->type);
sprintf(tbuf, "TYPE%u", key->type);
t = tbuf;
}
@ -709,8 +709,8 @@ int dns_resource_record_to_string(const DnsResourceRecord *rr, char **ret) {
if (!t)
return -ENOMEM;
s = strjoin(k, " ", t, NULL);
if (!s)
r = asprintf(&s, "%s \\# %"PRIu8" %s", k, rr->generic.size, t);
if (r < 0)
return -ENOMEM;
break;
}