Commit 5466ce3f authored by Andreas Gustafsson's avatar Andreas Gustafsson
Browse files

fromstruct_* functions needlessly used dns_name_towire() to do

a simple name data copy, thereby requiring a non-NULL mctx
parent f830ac67
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: rdata.c,v 1.83 2000/05/02 16:36:22 explorer Exp $ */
/* $Id: rdata.c,v 1.84 2000/05/05 18:14:59 gson Exp $ */
#include <config.h>
......@@ -83,6 +83,7 @@ static isc_result_t uint16_tobuffer(isc_uint32_t,
isc_buffer_t *target);
static isc_result_t uint8_tobuffer(isc_uint32_t value,
isc_buffer_t *target);
static isc_result_t name_tobuffer(dns_name_t *name, isc_buffer_t *target);
static isc_uint32_t uint32_fromregion(isc_region_t *region);
static isc_uint16_t uint16_fromregion(isc_region_t *region);
static isc_uint8_t uint8_fromregion(isc_region_t *region);
......@@ -1165,6 +1166,13 @@ uint8_tobuffer(isc_uint32_t value, isc_buffer_t *target) {
return (ISC_R_SUCCESS);
}
static isc_result_t
name_tobuffer(dns_name_t *name, isc_buffer_t *target) {
isc_region_t r;
dns_name_toregion(name, &r);
return (isc_buffer_copyregion(target, &r));
}
static isc_uint32_t
uint32_fromregion(isc_region_t *region) {
unsigned long value;
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: tsig_250.c,v 1.32 2000/05/04 22:19:05 gson Exp $ */
/* $Id: tsig_250.c,v 1.33 2000/05/05 18:15:00 gson Exp $ */
/* Reviewed: Thu Mar 16 13:39:43 PST 2000 by gson */
......@@ -294,19 +294,14 @@ fromstruct_any_tsig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
{
isc_region_t tr;
dns_rdata_any_tsig_t *tsig;
dns_compress_t cctx;
REQUIRE(type == 250);
REQUIRE(rdclass == 255);
tsig = (dns_rdata_any_tsig_t *) source;
REQUIRE(tsig->mctx != NULL);
tsig = (dns_rdata_any_tsig_t *)source;
/* Algorithm Name */
RETERR(dns_compress_init(&cctx, -1, tsig->mctx));
dns_compress_setmethods(&cctx, DNS_COMPRESS_NONE);
RETERR(dns_name_towire(&tsig->algorithm, &cctx, target));
dns_compress_invalidate(&cctx);
RETERR(name_tobuffer(&tsig->algorithm, target));
isc_buffer_availableregion(target, &tr);
if (tr.length < 6 + 2 + 2)
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: sig_24.c,v 1.37 2000/05/05 05:50:06 marka Exp $ */
/* $Id: sig_24.c,v 1.38 2000/05/05 18:15:01 gson Exp $ */
/* Reviewed: Fri Mar 17 09:05:02 PST 2000 by gson */
......@@ -301,14 +301,12 @@ fromstruct_sig(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
{
isc_region_t tr;
dns_rdata_sig_t *sig;
dns_compress_t cctx;
REQUIRE(type == 24);
UNUSED(rdclass);
sig = (dns_rdata_sig_t *) source;
REQUIRE(sig->mctx != NULL);
sig = (dns_rdata_sig_t *)source;
/* Type covered */
RETERR(uint16_tobuffer(sig->covered, target));
......@@ -332,10 +330,7 @@ fromstruct_sig(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
RETERR(uint16_tobuffer(sig->keyid, target));
/* Signer name */
RETERR(dns_compress_init(&cctx, -1, sig->mctx));
dns_compress_setmethods(&cctx, DNS_COMPRESS_NONE);
RETERR(dns_name_towire(&sig->signer, &cctx, target));
dns_compress_invalidate(&cctx);
RETERR(name_tobuffer(&sig->signer, target));
/* Signature */
if (sig->siglen > 0) {
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: tkey_249.c,v 1.30 2000/05/05 05:50:09 marka Exp $ */
/* $Id: tkey_249.c,v 1.31 2000/05/05 18:15:02 gson Exp $ */
/*
* Reviewed: Thu Mar 16 17:35:30 PST 2000 by halley.
......@@ -295,7 +295,6 @@ fromstruct_tkey(dns_rdataclass_t rdclass, dns_rdatatype_t type,
{
isc_region_t tr;
dns_rdata_tkey_t *tkey;
dns_compress_t cctx;
UNUSED(rdclass);
UNUSED(source);
......@@ -303,14 +302,10 @@ fromstruct_tkey(dns_rdataclass_t rdclass, dns_rdatatype_t type,
REQUIRE(type == 249);
tkey = (dns_rdata_tkey_t *) source;
REQUIRE(tkey->mctx != NULL);
tkey = (dns_rdata_tkey_t *)source;
/* Algorithm Name */
RETERR(dns_compress_init(&cctx, -1, tkey->mctx));
dns_compress_setmethods(&cctx, DNS_COMPRESS_NONE);
RETERR(dns_name_towire(&tkey->algorithm, &cctx, target));
dns_compress_invalidate(&cctx);
RETERR(name_tobuffer(&tkey->algorithm, target));
/* Inception: 32 bits */
RETERR(uint32_tobuffer(tkey->inception, target));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment