From 8248da3b836276b6dd782e597bb45ea7a05d1c26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 22 Sep 2021 18:55:02 +0200 Subject: [PATCH 1/2] 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. --- lib/isc/netmgr/netmgr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index 5b1ff7cdb8..a74047d763 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -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; } } From d717975e3e4fe5b246937a6bc9d5163eb7be751d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 22 Sep 2021 19:54:29 +0200 Subject: [PATCH 2/2] Add CHANGES and release notes for [GL #2917] --- CHANGES | 3 +++ doc/notes/notes-current.rst | 3 +++ 2 files changed, 6 insertions(+) diff --git a/CHANGES b/CHANGES index a777a0500e..d2a0f65f6e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +5722. [bug] Preserve the contents of TCPDNS and TLSDNS receive + buffer when growing the buffer size. [GL #2917] + 5721. [func] New isc_mem_reget() realloc-like function was introduced into the libisc API, and zero-sized allocations now return non-NULL pointers. [GL !5440] diff --git a/doc/notes/notes-current.rst b/doc/notes/notes-current.rst index cfa98cedde..46c66f04ad 100644 --- a/doc/notes/notes-current.rst +++ b/doc/notes/notes-current.rst @@ -62,3 +62,6 @@ Bug Fixes - When new IP addresses were added to the system during ``named`` startup, ``named`` failed to listen on TCP for the newly added interfaces. :gl:`#2852` + +- Under specific circumstances, zone transfers over TCP and TLS could be + interrupted prematurely. This has been fixed. :gl:`#2917`