From cfc22e53a89ccac4eb04b4f41a93f73e629e80ed Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Wed, 25 Nov 2009 05:55:32 +0000 Subject: [PATCH] 2789. [bug] Fixed an INSIST in dispatch.c [RT #20576] --- CHANGES | 2 ++ lib/dns/dispatch.c | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 782a0d893c..363b22820a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ +2789. [bug] Fixed an INSIST in dispatch.c [RT #20576] + 2788. [bug] dnssec-signzone could sign with keys that were not requested [RT #20625] diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c index e13230557e..947a48e97f 100644 --- a/lib/dns/dispatch.c +++ b/lib/dns/dispatch.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dispatch.c,v 1.164 2009/09/01 00:22:26 jinmei Exp $ */ +/* $Id: dispatch.c,v 1.165 2009/11/25 05:55:32 each Exp $ */ /*! \file */ @@ -778,6 +778,9 @@ new_portentry(dns_dispatch_t *disp, in_port_t port) { return (portentry); } +/*% + * The caller must not hold the qid->lock. + */ static void deref_portentry(dns_dispatch_t *disp, dispportentry_t **portentryp) { dispportentry_t *portentry = *portentryp; @@ -785,6 +788,9 @@ deref_portentry(dns_dispatch_t *disp, dispportentry_t **portentryp) { REQUIRE(disp->port_table != NULL); REQUIRE(portentry != NULL && portentry->refs > 0); + dns_qid_t *qid; + qid = DNS_QID(disp); + LOCK(&qid->lock); portentry->refs--; if (portentry->refs == 0) { ISC_LIST_UNLINK(disp->port_table[portentry->port % @@ -794,6 +800,7 @@ deref_portentry(dns_dispatch_t *disp, dispportentry_t **portentryp) { } *portentryp = NULL; + UNLOCK(&qid->lock); } /*% @@ -811,8 +818,9 @@ socket_search(dns_qid_t *qid, isc_sockaddr_t *dest, in_port_t port, dispsock = ISC_LIST_HEAD(qid->sock_table[bucket]); while (dispsock != NULL) { - if (isc_sockaddr_equal(dest, &dispsock->host) && - dispsock->portentry->port == port) + if (dispsock->portentry != NULL && + dispsock->portentry->port == port && + isc_sockaddr_equal(dest, &dispsock->host)) return (dispsock); dispsock = ISC_LIST_NEXT(dispsock, blink); }