2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

Merge branch '4671-calling-dns_qpkey_toname-twice-fails' into 'main'

Resolve "Calling dns_qpkey_toname twice fails."

Closes #4671

See merge request isc-projects/bind9!8948
This commit is contained in:
Mark Andrews
2024-04-18 01:05:42 +00:00
2 changed files with 6 additions and 3 deletions

View File

@@ -259,13 +259,12 @@ dns_qpkey_toname(const dns_qpkey_t key, size_t keylen, dns_name_t *name) {
REQUIRE(name->buffer != NULL);
REQUIRE(name->offsets != NULL);
dns_name_reset(name);
if (keylen == 0) {
dns_name_reset(name);
return;
}
isc_buffer_clear(name->buffer);
/* Scan the key looking for label boundaries */
for (offset = 0; offset <= keylen; offset++) {
INSIST(key[offset] >= SHIFT_NOBYTE &&

View File

@@ -94,6 +94,7 @@ ISC_RUN_TEST_IMPL(qpkey_name) {
dns_qpkey_t key;
dns_fixedname_t fn1, fn2;
dns_name_t *in = NULL, *out = NULL;
char namebuf[DNS_NAME_FORMATSIZE];
in = dns_fixedname_initname(&fn1);
if (testcases[i].len != 0) {
@@ -111,6 +112,9 @@ ISC_RUN_TEST_IMPL(qpkey_name) {
out = dns_fixedname_initname(&fn2);
dns_qpkey_toname(key, len, out);
assert_true(dns_name_equal(in, out));
/* check that 'out' is properly reset by dns_qpkey_toname */
dns_qpkey_toname(key, len, out);
dns_name_format(out, namebuf, sizeof(namebuf));
}
}