]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Lock dispatch manager buffer_lock before accessing buffers;
authorMark Andrews <marka@isc.org>
Fri, 22 Nov 2019 01:55:03 +0000 (12:55 +1100)
committerMark Andrews <marka@isc.org>
Mon, 25 Nov 2019 23:39:45 +0000 (23:39 +0000)
Only test buffers for UDP dispatches.

lib/dns/dispatch.c

index 6cd2fd7fe35d27382e5e1ec8e34deb87da1c0ed8..2e534d26c3bf819093784651a733292170f43b23 100644 (file)
@@ -1500,8 +1500,14 @@ startrecv(dns_dispatch_t *disp, dispsocket_t *dispsock) {
        if (disp->recv_pending != 0 && dispsock == NULL)
                return (ISC_R_SUCCESS);
 
-       if (disp->mgr->buffers >= disp->mgr->maxbuffers)
-               return (ISC_R_NOMEMORY);
+       if (disp->socktype == isc_sockettype_udp) {
+               LOCK(&disp->mgr->buffer_lock);
+               if (disp->mgr->buffers >= disp->mgr->maxbuffers) {
+                       UNLOCK(&disp->mgr->buffer_lock);
+                       return (ISC_R_NOMEMORY);
+               }
+               UNLOCK(&disp->mgr->buffer_lock);
+       }
 
        if ((disp->attributes & DNS_DISPATCHATTR_EXCLUSIVE) != 0 &&
            dispsock == NULL)