]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Don't use stack allocated buffer for uv_write()
authorOndřej Surý <ondrej@isc.org>
Thu, 3 Dec 2020 07:33:21 +0000 (08:33 +0100)
committerOndřej Surý <ondrej@sury.org>
Thu, 3 Dec 2020 07:58:16 +0000 (08:58 +0100)
On FreeBSD, the stack is destroyed more aggressively than on Linux and
that revealed a bug where we were allocating the 16-bit len for the
TCPDNS message on the stack and the buffer got garbled before the
uv_write() sendback was executed.  Now, the len is part of the uvreq, so
we can safely pass it to the uv_write() as the req gets destroyed after
the sendcb is executed.

bin/tests/system/ixfr/prereq.sh [deleted file]
bin/tests/system/xfer/prereq.sh [deleted file]
lib/isc/netmgr/netmgr-int.h
lib/isc/netmgr/tcpdns.c
util/copyrights

diff --git a/bin/tests/system/ixfr/prereq.sh b/bin/tests/system/ixfr/prereq.sh
deleted file mode 100755 (executable)
index 55d18ac..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, you can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# See the COPYRIGHT file distributed with this work for additional
-# information regarding copyright ownership.
-
-. ../conf.sh
-
-if [ "$(uname -s)" != "Linux" ]; then
-    echo_i "This test is currently broken on non-Linux platforms"
-    exit 255
-fi
-
-exit 0
diff --git a/bin/tests/system/xfer/prereq.sh b/bin/tests/system/xfer/prereq.sh
deleted file mode 100755 (executable)
index 55d18ac..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, you can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# See the COPYRIGHT file distributed with this work for additional
-# information regarding copyright ownership.
-
-. ../conf.sh
-
-if [ "$(uname -s)" != "Linux" ]; then
-    echo_i "This test is currently broken on non-Linux platforms"
-    exit 255
-fi
-
-exit 0
index fe7fc7bd9b1b9ba691a3a18c3a3e73691176a893..4ffe61a1b8b338d5f9d624c0f4a9533a7ed57733 100644 (file)
@@ -287,6 +287,7 @@ struct isc__nm_uvreq {
        int magic;
        isc_nmsocket_t *sock;
        isc_nmhandle_t *handle;
+       char tcplen[2];       /* The TCP DNS message length */
        uv_buf_t uvbuf;       /* translated isc_region_t, to be
                               * sent or received */
        isc_sockaddr_t local; /* local address */
index 0b976ecdc5ccc6e04019b450a4dde590538e9529..9d55f9412d294bd636da39a1b752c4211f8e4155 100644 (file)
@@ -1238,6 +1238,7 @@ isc__nm_tcpdns_send(isc_nmhandle_t *handle, isc_region_t *region,
        REQUIRE(sock->type == isc_nm_tcpdnssocket);
 
        uvreq = isc__nm_uvreq_get(sock->mgr, sock);
+       *(uint16_t *)uvreq->tcplen = htons(region->length);
        uvreq->uvbuf.base = (char *)region->base;
        uvreq->uvbuf.len = region->length;
 
@@ -1300,8 +1301,7 @@ tcpdns_send_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
        REQUIRE(sock->type == isc_nm_tcpdnssocket);
 
        int r;
-       uint16_t len = htons(req->uvbuf.len);
-       uv_buf_t bufs[2] = { { .base = (char *)&len, .len = 2 },
+       uv_buf_t bufs[2] = { { .base = req->tcplen, .len = 2 },
                             { .base = req->uvbuf.base,
                               .len = req->uvbuf.len } };
 
index 78903dea7b4414ac2ae5e0a98915aa5d7d83dcaf..bebc950682e11b12c1b1bb87dfc9a094c1dbbd86 100644 (file)
 ./bin/tests/system/ixfr/ans2/startme           X       2011,2018,2019,2020
 ./bin/tests/system/ixfr/clean.sh               SH      2001,2004,2007,2011,2012,2014,2015,2016,2018,2019,2020
 ./bin/tests/system/ixfr/ixfr-stats.good                X       2019,2020
-./bin/tests/system/ixfr/prereq.sh              SH      2020
 ./bin/tests/system/ixfr/setup.sh               SH      2001,2004,2007,2011,2012,2013,2014,2016,2018,2019,2020
 ./bin/tests/system/ixfr/tests.sh               SH      2001,2004,2007,2011,2012,2014,2016,2018,2019,2020
 ./bin/tests/system/kasp/README                 TXT.BRIEF       2019,2020
 ./bin/tests/system/xfer/dig2.good              X       2000,2001,2003,2004,2009,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020
 ./bin/tests/system/xfer/knowngood.mapped       X       2016,2018,2019,2020
 ./bin/tests/system/xfer/ns4/named.conf.base    X       2011,2013,2016,2018,2019,2020
-./bin/tests/system/xfer/prereq.sh              SH      2020
 ./bin/tests/system/xfer/setup.sh               SH      2001,2002,2004,2007,2011,2012,2013,2014,2015,2016,2018,2019,2020
 ./bin/tests/system/xfer/tests.sh               SH      2000,2001,2004,2005,2007,2011,2012,2013,2014,2015,2016,2018,2019,2020
 ./bin/tests/system/xferquota/clean.sh          SH      2000,2001,2004,2007,2012,2014,2015,2016,2018,2019,2020