Calling dns_qpkey_toname twice fails.
e.g. in fix_iterator the following failed.
dns_fixedname_t fixed;
dns_name_t *name = dns_fixedname_initname(&fixed);
char namebuf[DNS_NAME_FORMATSIZE];
char foundbuf[DNS_NAME_FORMATSIZE];
dns_qpkey_toname(search, searchlen, name);
dns_name_format(name, namebuf, sizeof(namebuf));
dns_qpkey_toname(found, foundlen, name);
dns_name_format(name, foundbuf, sizeof(foundbuf));
diff --git a/lib/dns/qp.c b/lib/dns/qp.c
index dff011ba668..412c92dcb00 100644
--- a/lib/dns/qp.c
+++ b/lib/dns/qp.c
@@ -292,6 +292,7 @@ scanned:
* through the labels, to create the DNS wire format data.
*/
name->labels = loc;
+ name->length = 0;
while (loc-- > 0) {
uint8_t len = 0, *lenp = NULL;