Commit a0e3c096d7 for bind
commit a0e3c096d728d70f7d3646cc5459f7029c658b4e
Author: Martin Basti <mbasti@isc.org>
Date: Mon Aug 31 17:51:50 2026 +0000
Merge the old and new form branches in dns_private_totext
The two branches were identical apart from where the algorithm number
is read from, and only the new form received the dst_algorithm_format
fix. Share the common tail so they cannot drift apart again;
dst_algorithm_format produces the same text as dns_secalg_format for
all algorithm numbers below 256, so old form output is unchanged.
Assisted-by: Claude:claude-fable-5
diff --git a/lib/dns/private.c b/lib/dns/private.c
index e3be3131e9..11ebea16d4 100644
--- a/lib/dns/private.c
+++ b/lib/dns/private.c
@@ -344,40 +344,23 @@ dns_private_totext(dns_rdata_t *private, isc_buffer_t *buf) {
if (del && !nonsec) {
isc_buffer_putstr(buf, " / creating NSEC chain");
}
- } else if (private->length == 5) {
- /* Old Form */
- unsigned char alg = private->data[0];
- dns_keytag_t keyid = (private->data[2] | private->data[1] << 8);
- char keybuf[DNS_SECALG_FORMATSIZE + BUFSIZ],
- algbuf[DNS_SECALG_FORMATSIZE];
- bool del = private->data[3];
- bool complete = private->data[4];
-
- if (del && complete) {
- isc_buffer_putstr(buf, "Done removing signatures for ");
- } else if (del) {
- isc_buffer_putstr(buf, "Removing signatures for ");
- } else if (complete) {
- isc_buffer_putstr(buf, "Done signing with ");
- } else {
- isc_buffer_putstr(buf, "Signing with ");
- }
-
- dns_secalg_format(alg, algbuf, sizeof(algbuf));
- snprintf(keybuf, sizeof(keybuf), "key %d/%s", keyid, algbuf);
- isc_buffer_putstr(buf, keybuf);
- } else if (private->length == 7) {
- /* New Form - supports private types */
+ } else if (private->length == 5 || private->length == 7) {
dns_keytag_t keyid = private->data[2] | (private->data[1] << 8);
- char keybuf[DNS_SECALG_FORMATSIZE + BUFSIZ],
- algbuf[DNS_SECALG_FORMATSIZE];
+ char keybuf[sizeof("key 65535/") + DST_ALG_FORMATSIZE],
+ algbuf[DST_ALG_FORMATSIZE];
bool del = private->data[3];
bool complete = private->data[4];
- dst_algorithm_t alg = private->data[6] |
- (private->data[5] << 8);
+ dst_algorithm_t alg;
- if (dst_algorithm_tosecalg(alg) != private->data[0]) {
- return ISC_R_NOTFOUND;
+ if (private->length == 5) {
+ /* Old Form */
+ alg = private->data[0];
+ } else {
+ /* New Form - supports private types */
+ alg = private->data[6] | (private->data[5] << 8);
+ if (dst_algorithm_tosecalg(alg) != private->data[0]) {
+ return ISC_R_NOTFOUND;
+ }
}
if (del && complete) {