2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Clone the saved / query message buffers

The message buffer passed to ns__client_request is only valid for
the life of the the ns__client_request call.  Save a copy of it
when we recurse or process a update as ns__client_request will
return before those operations complete.
This commit is contained in:
Mark Andrews
2020-09-18 15:00:35 +10:00
parent ab19d0a73d
commit f0d9bf7c30
5 changed files with 31 additions and 0 deletions

View File

@@ -4749,3 +4749,21 @@ dns_message_setpadding(dns_message_t *msg, uint16_t padding) {
}
msg->padding = padding;
}
void
dns_message_clonebuffer(dns_message_t *msg) {
REQUIRE(DNS_MESSAGE_VALID(msg));
if (msg->free_saved == 0 && msg->saved.base != NULL) {
msg->saved.base =
memmove(isc_mem_get(msg->mctx, msg->saved.length),
msg->saved.base, msg->saved.length);
msg->free_saved = 1;
}
if (msg->free_query == 0 && msg->query.base != NULL) {
msg->query.base =
memmove(isc_mem_get(msg->mctx, msg->query.length),
msg->query.base, msg->query.length);
msg->free_query = 1;
}
}