From c610d78e6773b57a1ead6db210c29355ba0bda19 Mon Sep 17 00:00:00 2001 From: Brian Wellington Date: Fri, 19 May 2000 22:11:20 +0000 Subject: [PATCH] changes to the rdata_tostruct api had broken tsig/tkey --- lib/dns/message.c | 27 ++++++++++++++++++++++++--- lib/dns/tkey.c | 8 ++++++-- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/lib/dns/message.c b/lib/dns/message.c index 8c393140a0..f6d3b73db6 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -502,14 +502,35 @@ msgreset(dns_message_t *msg, isc_boolean_t everything) { dns_compress_invalidate(&msg->cctx); if (msg->tsig != NULL) { - dns_rdata_freestruct(msg->tsig); + if (msg->from_to_wire == DNS_MESSAGE_INTENTPARSE) + dns_rdata_freestruct(msg->tsig); + else { + if (msg->tsig->signature != NULL) + isc_mem_put(msg->mctx, msg->tsig->signature, + msg->tsig->siglen); + if (msg->tsig->other != NULL) + isc_mem_put(msg->mctx, msg->tsig->other, + msg->tsig->otherlen); + dns_name_free(&msg->tsig->algorithm, msg->mctx); + } isc_mem_put(msg->mctx, msg->tsig, sizeof(dns_rdata_any_tsig_t)); msg->tsig = NULL; } if (msg->querytsig != NULL) { - dns_rdata_freestruct(msg->querytsig); + if (msg->from_to_wire != DNS_MESSAGE_INTENTPARSE) + dns_rdata_freestruct(msg->querytsig); + else { + if (msg->querytsig->signature != NULL) + isc_mem_put(msg->mctx, + msg->querytsig->signature, + msg->querytsig->siglen); + if (msg->querytsig->other != NULL) + isc_mem_put(msg->mctx, msg->querytsig->other, + msg->querytsig->otherlen); + dns_name_free(&msg->querytsig->algorithm, msg->mctx); + } isc_mem_put(msg->mctx, msg->querytsig, sizeof(dns_rdata_any_tsig_t)); msg->querytsig = NULL; @@ -659,8 +680,8 @@ dns_message_reset(dns_message_t *msg, unsigned int intent) { REQUIRE(intent == DNS_MESSAGE_INTENTPARSE || intent == DNS_MESSAGE_INTENTRENDER); - msg->from_to_wire = intent; msgreset(msg, ISC_FALSE); + msg->from_to_wire = intent; } void diff --git a/lib/dns/tkey.c b/lib/dns/tkey.c index 849d0b9065..5f20d9e218 100644 --- a/lib/dns/tkey.c +++ b/lib/dns/tkey.c @@ -16,7 +16,7 @@ */ /* - * $Id: tkey.c,v 1.36 2000/05/19 00:20:52 bwelling Exp $ + * $Id: tkey.c,v 1.37 2000/05/19 22:11:20 bwelling Exp $ * Principal Author: Brian Wellington */ @@ -611,7 +611,11 @@ dns_tkey_processquery(dns_message_t *msg, dns_tkey_ctx_t *tctx, RETERR(isc_buffer_allocate(msg->mctx, &dynbuf, 128)); result = dns_rdata_fromstruct(rdata, tkeyout.common.rdclass, tkeyout.common.rdtype, &tkeyout, dynbuf); - dns_rdata_freestruct(&tkeyout); + dns_name_free(&tkeyout.algorithm, msg->mctx); + if (tkeyout.key != NULL) + isc_mem_put(msg->mctx, tkeyout.key, tkeyout.keylen); + if (tkeyout.other != NULL) + isc_mem_put(msg->mctx, tkeyout.other, tkeyout.otherlen); if (result != ISC_R_SUCCESS) goto failure;