mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
Preserve the contents of socket buffer on realloc
On TCPDNS/TLSDNS read callback, the socket buffer could be reallocated if the received contents would be larger than the buffer. The existing code would not preserve the contents of the existing buffer which lead to the loss of the already received data. This commit changes the isc_mem_put()+isc_mem_get() with isc_mem_reget() to preserve the existing contents of the socket buffer.
This commit is contained in:
@@ -1894,8 +1894,8 @@ isc__nm_alloc_dnsbuf(isc_nmsocket_t *sock, size_t len) {
|
||||
sock->buf_size = alloc_len;
|
||||
} else {
|
||||
/* We have the buffer but it's too small */
|
||||
isc_mem_put(sock->mgr->mctx, sock->buf, sock->buf_size);
|
||||
sock->buf = isc_mem_get(sock->mgr->mctx, NM_BIG_BUF);
|
||||
sock->buf = isc_mem_reget(sock->mgr->mctx, sock->buf,
|
||||
sock->buf_size, NM_BIG_BUF);
|
||||
sock->buf_size = NM_BIG_BUF;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user