From dc19dcbc236bc876a6cdb426ec7c5fab964f8dfc Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 2 Jan 2008 04:24:59 +0000 Subject: [PATCH] 2283. [bug] TSIG keys were not attaching to the memory context. TSIG keys should use the rings memory context rather than the clients memory context. [RT #17377] --- CHANGES | 5 +++++ lib/dns/tkey.c | 10 +++++----- lib/dns/tsig.c | 12 +++++++----- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CHANGES b/CHANGES index 8be16b9b91..3cad1cb6ff 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +2283. [bug] TSIG keys were not attaching to the memory + context. TSIG keys should use the rings + memory context rather than the clients memory + context. [RT #17377] + 2282. [bug] Acl code fixups. [RT #17346] [RT #17374] 2281. [bug] Attempts to use undefined acls were not being logged. diff --git a/lib/dns/tkey.c b/lib/dns/tkey.c index fdc879b6ca..2b17e29a4a 100644 --- a/lib/dns/tkey.c +++ b/lib/dns/tkey.c @@ -16,7 +16,7 @@ */ /* - * $Id: tkey.c,v 1.86 2007/06/19 23:47:16 tbox Exp $ + * $Id: tkey.c,v 1.87 2008/01/02 04:24:59 marka Exp $ */ /*! \file */ #include @@ -393,7 +393,7 @@ process_dhtkey(dns_message_t *msg, dns_name_t *signer, dns_name_t *name, isc_buffer_base(&secret), isc_buffer_usedlength(&secret), ISC_TRUE, signer, tkeyin->inception, - tkeyin->expire, msg->mctx, ring, NULL)); + tkeyin->expire, ring->mctx, ring, NULL)); /* This key is good for a long time */ tkeyout->inception = tkeyin->inception; @@ -485,7 +485,7 @@ process_gsstkey(dns_message_t *msg, dns_name_t *signer, dns_name_t *name, dns_fixedname_name(&principal), tkeyin->inception, tkeyin->expire, - msg->mctx, ring, NULL)); + ring->mctx, ring, NULL)); } isc_stdtime_get(&now); @@ -1270,7 +1270,7 @@ dns_tkey_processgssresponse(dns_message_t *qmsg, dns_message_t *rmsg, RETERR(dns_tsigkey_createfromkey(tkeyname, DNS_TSIG_GSSAPI_NAME, dstkey, ISC_FALSE, NULL, rtkey.inception, rtkey.expire, - rmsg->mctx, ring, outkey)); + ring->mctx, ring, outkey)); dns_rdata_freestruct(&rtkey); return (result); @@ -1405,7 +1405,7 @@ dns_tkey_gssnegotiate(dns_message_t *qmsg, dns_message_t *rmsg, : DNS_TSIG_GSSAPI_NAME), dstkey, ISC_TRUE, NULL, rtkey.inception, rtkey.expire, - rmsg->mctx, ring, outkey)); + ring->mctx, ring, outkey)); dns_rdata_freestruct(&rtkey); return (result); diff --git a/lib/dns/tsig.c b/lib/dns/tsig.c index 5ab20a348c..41cd69b951 100644 --- a/lib/dns/tsig.c +++ b/lib/dns/tsig.c @@ -16,7 +16,7 @@ */ /* - * $Id: tsig.c,v 1.130 2007/09/24 17:18:25 each Exp $ + * $Id: tsig.c,v 1.131 2008/01/02 04:24:59 marka Exp $ */ /*! \file */ #include @@ -341,7 +341,8 @@ dns_tsigkey_createfromkey(dns_name_t *name, dns_name_t *algorithm, tkey->generated = generated; tkey->inception = inception; tkey->expire = expire; - tkey->mctx = mctx; + tkey->mctx = NULL; + isc_mem_attach(mctx, &tkey->mctx); tkey->magic = TSIG_MAGIC; @@ -603,7 +604,7 @@ tsigkey_free(dns_tsigkey_t *key) { isc_mem_put(key->mctx, key->creator, sizeof(dns_name_t)); } isc_refcount_destroy(&key->refs); - isc_mem_put(key->mctx, key, sizeof(dns_tsigkey_t)); + isc_mem_putanddetach(&key->mctx, key, sizeof(dns_tsigkey_t)); } void @@ -1525,8 +1526,9 @@ dns_tsigkeyring_create(isc_mem_t *mctx, dns_tsig_keyring_t **ringp) { return (result); } - ring->mctx = mctx; ring->writecount = 0; + ring->mctx = NULL; + isc_mem_attach(mctx, &ring->mctx); *ringp = ring; return (ISC_R_SUCCESS); @@ -1544,5 +1546,5 @@ dns_tsigkeyring_destroy(dns_tsig_keyring_t **ringp) { dns_rbt_destroy(&ring->keys); isc_rwlock_destroy(&ring->lock); - isc_mem_put(ring->mctx, ring, sizeof(dns_tsig_keyring_t)); + isc_mem_putanddetach(&ring->mctx, ring, sizeof(dns_tsig_keyring_t)); }