Commit 90f37119f3 for bind
commit 90f37119f3ead51cb9579fe200d292dab5d9ca0b
Author: Mark Andrews <marka@isc.org>
Date: Thu Oct 8 11:56:43 2026 +1100
Test that DST_ALG_FORMATSIZE is big enough
DST_ALG_FORMATSIZE should be big enough that dst_algorithm_totext
will succeed for every possible algorithm value allowing for the
NUL byte added by dst_algorithm_format.
diff --git a/tests/dns/dst_test.c b/tests/dns/dst_test.c
index d73718af85..0c97dfba75 100644
--- a/tests/dns/dst_test.c
+++ b/tests/dns/dst_test.c
@@ -122,6 +122,29 @@ ISC_RUN_TEST_IMPL(algorithm_format) {
}
}
+ISC_RUN_TEST_IMPL(algorithm_totext) {
+ /*
+ * Checks that DST_ALG_FORMATSIZE is big enough
+ * by asserting ISC_R_SUCCESS. Subtract 1 to allow
+ * for terminating NUL added in dst_algorithm_format.
+ */
+ char algstr[DST_ALG_FORMATSIZE - 1];
+ isc_buffer_t b;
+ isc_result_t result;
+
+ /* Assigned range. */
+ for (dst_algorithm_t i = 0; i < DST_MAX_ALGS; i++) {
+ isc_buffer_init(&b, algstr, sizeof(algstr));
+ result = dst_algorithm_totext(i, &b);
+ assert_int_equal(result, ISC_R_SUCCESS);
+ }
+
+ /* Maximum possible value. */
+ isc_buffer_init(&b, algstr, sizeof(algstr));
+ result = dst_algorithm_totext((dst_algorithm_t)~0, &b);
+ assert_int_equal(result, ISC_R_SUCCESS);
+}
+
ISC_RUN_TEST_IMPL(key_format) {
isc_result_t result;
dst_key_t *key = NULL;
@@ -601,6 +624,7 @@ ISC_RUN_TEST_IMPL(ecdsa_determinism_test) {
ISC_TEST_LIST_START
ISC_TEST_ENTRY(algorithm_fromdata)
ISC_TEST_ENTRY(algorithm_format)
+ISC_TEST_ENTRY(algorithm_totext)
ISC_TEST_ENTRY(key_format)
ISC_TEST_ENTRY(sig_test)
ISC_TEST_ENTRY(cmp_test)