bc1778ead1
* Fri Jun 24 2022 Florian Weimer <fweimer@redhat.com> - 2.34-39 - Add the no-aaaa DNS stub resolver option (#2096191) Resolves: #2096191
68 lines
2.4 KiB
Diff
68 lines
2.4 KiB
Diff
commit 62a321b12d0e397af88fa422db65079332f971dc
|
|
Author: Florian Weimer <fweimer@redhat.com>
|
|
Date: Fri Jun 24 18:16:41 2022 +0200
|
|
|
|
support: Change non-address output format of support_format_dns_packet
|
|
|
|
It makes sense to include the owner name (LHS) and record type in the
|
|
output, so that they can be checked for correctness.
|
|
|
|
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
|
|
|
|
diff --git a/support/support_format_dns_packet.c b/support/support_format_dns_packet.c
|
|
index 1f8e9ca172a06f4f..c3dff0e019801904 100644
|
|
--- a/support/support_format_dns_packet.c
|
|
+++ b/support/support_format_dns_packet.c
|
|
@@ -101,6 +101,17 @@ extract_name (struct in_buffer full, struct in_buffer *in, struct dname *value)
|
|
return true;
|
|
}
|
|
|
|
+static void
|
|
+extract_name_data (struct in_buffer full, struct in_buffer *rdata,
|
|
+ const struct dname *owner, const char *typename, FILE *out)
|
|
+{
|
|
+ struct dname name;
|
|
+ if (extract_name (full, rdata, &name))
|
|
+ fprintf (out, "data: %s %s %s\n", owner->name, typename, name.name);
|
|
+ else
|
|
+ fprintf (out, "error: malformed CNAME/PTR record\n");
|
|
+}
|
|
+
|
|
char *
|
|
support_format_dns_packet (const unsigned char *buffer, size_t length)
|
|
{
|
|
@@ -206,14 +217,11 @@ support_format_dns_packet (const unsigned char *buffer, size_t length)
|
|
}
|
|
break;
|
|
case T_CNAME:
|
|
+ extract_name_data (full, &rdata, &rname, "CNAME", mem.out);
|
|
+ break;
|
|
case T_PTR:
|
|
- {
|
|
- struct dname name;
|
|
- if (extract_name (full, &rdata, &name))
|
|
- fprintf (mem.out, "name: %s\n", name.name);
|
|
- else
|
|
- fprintf (mem.out, "error: malformed CNAME/PTR record\n");
|
|
- }
|
|
+ extract_name_data (full, &rdata, &rname, "PTR", mem.out);
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
diff --git a/support/tst-support_format_dns_packet.c b/support/tst-support_format_dns_packet.c
|
|
index 03ff59457e3bdde8..5596db1785009557 100644
|
|
--- a/support/tst-support_format_dns_packet.c
|
|
+++ b/support/tst-support_format_dns_packet.c
|
|
@@ -85,8 +85,8 @@ test_multiple_cnames (void)
|
|
"\xc0\x00\x02\x01";
|
|
check_packet (packet, sizeof (packet) - 1, __func__,
|
|
"name: www.example\n"
|
|
- "name: www1.example\n"
|
|
- "name: www2.example\n"
|
|
+ "data: www.example CNAME www1.example\n"
|
|
+ "data: www1.example CNAME www2.example\n"
|
|
"address: 192.0.2.1\n");
|
|
}
|
|
|