mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
Merge branch 'each-mem-maybedup' into 'main'
mem_maybedup() can no longer fail See merge request isc-projects/bind9!5835
This commit is contained in:
commit
e2636b1de0
43 changed files with 23 additions and 367 deletions
|
|
@ -523,7 +523,7 @@ dns_rdata_tostruct(const dns_rdata_t *rdata, void *target, isc_mem_t *mctx);
|
|||
*
|
||||
* Result:
|
||||
*\li Success
|
||||
*\li Resource Limit: Not enough memory
|
||||
*\li Not Implemented
|
||||
*/
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -420,11 +420,14 @@ name_duporclone(const dns_name_t *source, isc_mem_t *mctx, dns_name_t *target) {
|
|||
|
||||
static inline void *
|
||||
mem_maybedup(isc_mem_t *mctx, void *source, size_t length) {
|
||||
void *copy;
|
||||
void *copy = NULL;
|
||||
|
||||
REQUIRE(source != NULL);
|
||||
|
||||
if (mctx == NULL) {
|
||||
return (source);
|
||||
}
|
||||
|
||||
copy = isc_mem_allocate(mctx, length);
|
||||
memmove(copy, source, length);
|
||||
|
||||
|
|
|
|||
|
|
@ -496,9 +496,6 @@ tostruct_any_tsig(ARGS_TOSTRUCT) {
|
|||
*/
|
||||
INSIST(sr.length >= tsig->siglen);
|
||||
tsig->signature = mem_maybedup(mctx, sr.base, tsig->siglen);
|
||||
if (tsig->signature == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
isc_region_consume(&sr, tsig->siglen);
|
||||
|
||||
/*
|
||||
|
|
@ -524,21 +521,9 @@ tostruct_any_tsig(ARGS_TOSTRUCT) {
|
|||
*/
|
||||
INSIST(sr.length == tsig->otherlen);
|
||||
tsig->other = mem_maybedup(mctx, sr.base, tsig->otherlen);
|
||||
if (tsig->other == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
tsig->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
if (mctx != NULL) {
|
||||
dns_name_free(&tsig->algorithm, tsig->mctx);
|
||||
}
|
||||
if (mctx != NULL && tsig->signature != NULL) {
|
||||
isc_mem_free(mctx, tsig->signature);
|
||||
}
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
|
|||
|
|
@ -360,9 +360,6 @@ tostruct_amtrelay(ARGS_TOSTRUCT) {
|
|||
if (region.length != 0) {
|
||||
amtrelay->data = mem_maybedup(mctx, region.base,
|
||||
region.length);
|
||||
if (amtrelay->data == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
}
|
||||
amtrelay->length = region.length;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -507,31 +507,20 @@ tostruct_caa(ARGS_TOSTRUCT) {
|
|||
/*
|
||||
* Flags
|
||||
*/
|
||||
if (sr.length < 1) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
}
|
||||
caa->flags = uint8_fromregion(&sr);
|
||||
isc_region_consume(&sr, 1);
|
||||
|
||||
/*
|
||||
* Tag length
|
||||
*/
|
||||
if (sr.length < 1) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
}
|
||||
caa->tag_len = uint8_fromregion(&sr);
|
||||
isc_region_consume(&sr, 1);
|
||||
|
||||
/*
|
||||
* Tag
|
||||
*/
|
||||
if (sr.length < caa->tag_len) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
}
|
||||
INSIST(sr.length >= caa->tag_len);
|
||||
caa->tag = mem_maybedup(mctx, sr.base, caa->tag_len);
|
||||
if (caa->tag == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
isc_region_consume(&sr, caa->tag_len);
|
||||
|
||||
/*
|
||||
|
|
@ -539,9 +528,6 @@ tostruct_caa(ARGS_TOSTRUCT) {
|
|||
*/
|
||||
caa->value_len = sr.length;
|
||||
caa->value = mem_maybedup(mctx, sr.base, sr.length);
|
||||
if (caa->value == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
caa->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -207,10 +207,6 @@ tostruct_cert(ARGS_TOSTRUCT) {
|
|||
cert->length = region.length;
|
||||
|
||||
cert->certificate = mem_maybedup(mctx, region.base, region.length);
|
||||
if (cert->certificate == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
cert->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,15 +183,8 @@ tostruct_csync(ARGS_TOSTRUCT) {
|
|||
|
||||
csync->len = region.length;
|
||||
csync->typebits = mem_maybedup(mctx, region.base, region.length);
|
||||
if (csync->typebits == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
csync->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ tostruct_doa(ARGS_TOSTRUCT) {
|
|||
REQUIRE(rdata != NULL);
|
||||
REQUIRE(rdata->type == dns_rdatatype_doa);
|
||||
REQUIRE(doa != NULL);
|
||||
REQUIRE(rdata->length != 0);
|
||||
REQUIRE(rdata->length >= 10);
|
||||
|
||||
doa->common.rdclass = rdata->rdclass;
|
||||
doa->common.rdtype = rdata->type;
|
||||
|
|
@ -224,43 +224,28 @@ tostruct_doa(ARGS_TOSTRUCT) {
|
|||
/*
|
||||
* DOA-ENTERPRISE
|
||||
*/
|
||||
if (region.length < 4) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
}
|
||||
doa->enterprise = uint32_fromregion(®ion);
|
||||
isc_region_consume(®ion, 4);
|
||||
|
||||
/*
|
||||
* DOA-TYPE
|
||||
*/
|
||||
if (region.length < 4) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
}
|
||||
doa->type = uint32_fromregion(®ion);
|
||||
isc_region_consume(®ion, 4);
|
||||
|
||||
/*
|
||||
* DOA-LOCATION
|
||||
*/
|
||||
if (region.length < 1) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
}
|
||||
doa->location = uint8_fromregion(®ion);
|
||||
isc_region_consume(®ion, 1);
|
||||
|
||||
/*
|
||||
* DOA-MEDIA-TYPE
|
||||
*/
|
||||
if (region.length < 1) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
}
|
||||
doa->mediatype_len = uint8_fromregion(®ion);
|
||||
isc_region_consume(®ion, 1);
|
||||
INSIST(doa->mediatype_len <= region.length);
|
||||
doa->mediatype = mem_maybedup(mctx, region.base, doa->mediatype_len);
|
||||
if (doa->mediatype == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
isc_region_consume(®ion, doa->mediatype_len);
|
||||
|
||||
/*
|
||||
|
|
@ -270,21 +255,12 @@ tostruct_doa(ARGS_TOSTRUCT) {
|
|||
doa->data = NULL;
|
||||
if (doa->data_len > 0) {
|
||||
doa->data = mem_maybedup(mctx, region.base, doa->data_len);
|
||||
if (doa->data == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
isc_region_consume(®ion, doa->data_len);
|
||||
}
|
||||
|
||||
doa->mctx = mctx;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
if (mctx != NULL && doa->mediatype != NULL) {
|
||||
isc_mem_free(mctx, doa->mediatype);
|
||||
}
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
|
|||
|
|
@ -293,10 +293,6 @@ generic_tostruct_ds(ARGS_TOSTRUCT) {
|
|||
ds->length = region.length;
|
||||
|
||||
ds->digest = mem_maybedup(mctx, region.base, region.length);
|
||||
if (ds->digest == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
ds->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,43 +140,23 @@ tostruct_gpos(ARGS_TOSTRUCT) {
|
|||
gpos->long_len = uint8_fromregion(®ion);
|
||||
isc_region_consume(®ion, 1);
|
||||
gpos->longitude = mem_maybedup(mctx, region.base, gpos->long_len);
|
||||
if (gpos->longitude == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
isc_region_consume(®ion, gpos->long_len);
|
||||
|
||||
gpos->lat_len = uint8_fromregion(®ion);
|
||||
isc_region_consume(®ion, 1);
|
||||
gpos->latitude = mem_maybedup(mctx, region.base, gpos->lat_len);
|
||||
if (gpos->latitude == NULL) {
|
||||
goto cleanup_longitude;
|
||||
}
|
||||
isc_region_consume(®ion, gpos->lat_len);
|
||||
|
||||
gpos->alt_len = uint8_fromregion(®ion);
|
||||
isc_region_consume(®ion, 1);
|
||||
if (gpos->lat_len > 0) {
|
||||
gpos->altitude = mem_maybedup(mctx, region.base, gpos->alt_len);
|
||||
if (gpos->altitude == NULL) {
|
||||
goto cleanup_latitude;
|
||||
}
|
||||
} else {
|
||||
gpos->altitude = NULL;
|
||||
}
|
||||
|
||||
gpos->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup_latitude:
|
||||
if (mctx != NULL && gpos->longitude != NULL) {
|
||||
isc_mem_free(mctx, gpos->longitude);
|
||||
}
|
||||
|
||||
cleanup_longitude:
|
||||
if (mctx != NULL && gpos->latitude != NULL) {
|
||||
isc_mem_free(mctx, gpos->latitude);
|
||||
}
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
|
|||
|
|
@ -125,26 +125,13 @@ tostruct_hinfo(ARGS_TOSTRUCT) {
|
|||
hinfo->cpu_len = uint8_fromregion(®ion);
|
||||
isc_region_consume(®ion, 1);
|
||||
hinfo->cpu = mem_maybedup(mctx, region.base, hinfo->cpu_len);
|
||||
if (hinfo->cpu == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
isc_region_consume(®ion, hinfo->cpu_len);
|
||||
|
||||
hinfo->os_len = uint8_fromregion(®ion);
|
||||
isc_region_consume(®ion, 1);
|
||||
hinfo->os = mem_maybedup(mctx, region.base, hinfo->os_len);
|
||||
if (hinfo->os == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
hinfo->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
if (mctx != NULL && hinfo->cpu != NULL) {
|
||||
isc_mem_free(mctx, hinfo->cpu);
|
||||
}
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
|
|||
|
|
@ -322,42 +322,21 @@ tostruct_hip(ARGS_TOSTRUCT) {
|
|||
hip->hit = hip->key = hip->servers = NULL;
|
||||
|
||||
hip->hit = mem_maybedup(mctx, region.base, hip->hit_len);
|
||||
if (hip->hit == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
isc_region_consume(®ion, hip->hit_len);
|
||||
|
||||
INSIST(hip->key_len <= region.length);
|
||||
|
||||
hip->key = mem_maybedup(mctx, region.base, hip->key_len);
|
||||
if (hip->key == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
isc_region_consume(®ion, hip->key_len);
|
||||
|
||||
hip->servers_len = region.length;
|
||||
if (hip->servers_len != 0) {
|
||||
hip->servers = mem_maybedup(mctx, region.base, region.length);
|
||||
if (hip->servers == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
hip->offset = hip->servers_len;
|
||||
hip->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
if (hip->hit != NULL) {
|
||||
isc_mem_free(mctx, hip->hit);
|
||||
}
|
||||
if (hip->key != NULL) {
|
||||
isc_mem_free(mctx, hip->key);
|
||||
}
|
||||
if (hip->servers != NULL) {
|
||||
isc_mem_free(mctx, hip->servers);
|
||||
}
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
|
|||
|
|
@ -353,10 +353,6 @@ tostruct_ipseckey(ARGS_TOSTRUCT) {
|
|||
REQUIRE(ipseckey != NULL);
|
||||
REQUIRE(rdata->length >= 3);
|
||||
|
||||
if (rdata->data[1] > 3U) {
|
||||
return (ISC_R_NOTIMPLEMENTED);
|
||||
}
|
||||
|
||||
ipseckey->common.rdclass = rdata->rdclass;
|
||||
ipseckey->common.rdtype = rdata->type;
|
||||
ISC_LINK_INIT(&ipseckey->common, link);
|
||||
|
|
@ -384,6 +380,7 @@ tostruct_ipseckey(ARGS_TOSTRUCT) {
|
|||
break;
|
||||
|
||||
case 2:
|
||||
INSIST(region.length >= 16U);
|
||||
memmove(ipseckey->in6_addr.s6_addr, region.base, 16);
|
||||
isc_region_consume(®ion, 16);
|
||||
break;
|
||||
|
|
@ -400,13 +397,6 @@ tostruct_ipseckey(ARGS_TOSTRUCT) {
|
|||
if (ipseckey->keylength != 0U) {
|
||||
ipseckey->key = mem_maybedup(mctx, region.base,
|
||||
ipseckey->keylength);
|
||||
if (ipseckey->key == NULL) {
|
||||
if (ipseckey->gateway_type == 3) {
|
||||
dns_name_free(&ipseckey->gateway,
|
||||
ipseckey->mctx);
|
||||
}
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
} else {
|
||||
ipseckey->key = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,9 +146,6 @@ tostruct_isdn(ARGS_TOSTRUCT) {
|
|||
isdn->isdn_len = uint8_fromregion(&r);
|
||||
isc_region_consume(&r, 1);
|
||||
isdn->isdn = mem_maybedup(mctx, r.base, isdn->isdn_len);
|
||||
if (isdn->isdn == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
isc_region_consume(&r, isdn->isdn_len);
|
||||
|
||||
if (r.length == 0) {
|
||||
|
|
@ -159,19 +156,10 @@ tostruct_isdn(ARGS_TOSTRUCT) {
|
|||
isc_region_consume(&r, 1);
|
||||
isdn->subaddress = mem_maybedup(mctx, r.base,
|
||||
isdn->subaddress_len);
|
||||
if (isdn->subaddress == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
isdn->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
if (mctx != NULL && isdn->isdn != NULL) {
|
||||
isc_mem_free(mctx, isdn->isdn);
|
||||
}
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ generic_tostruct_key(ARGS_TOSTRUCT) {
|
|||
isc_region_t sr;
|
||||
|
||||
REQUIRE(key != NULL);
|
||||
REQUIRE(rdata->length != 0);
|
||||
REQUIRE(rdata->length >= 4U);
|
||||
|
||||
REQUIRE(key != NULL);
|
||||
REQUIRE(key->common.rdclass == rdata->rdclass);
|
||||
|
|
@ -332,33 +332,20 @@ generic_tostruct_key(ARGS_TOSTRUCT) {
|
|||
dns_rdata_toregion(rdata, &sr);
|
||||
|
||||
/* Flags */
|
||||
if (sr.length < 2) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
}
|
||||
key->flags = uint16_fromregion(&sr);
|
||||
isc_region_consume(&sr, 2);
|
||||
|
||||
/* Protocol */
|
||||
if (sr.length < 1) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
}
|
||||
key->protocol = uint8_fromregion(&sr);
|
||||
isc_region_consume(&sr, 1);
|
||||
|
||||
/* Algorithm */
|
||||
if (sr.length < 1) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
}
|
||||
key->algorithm = uint8_fromregion(&sr);
|
||||
isc_region_consume(&sr, 1);
|
||||
|
||||
/* Data */
|
||||
key->datalen = sr.length;
|
||||
key->data = mem_maybedup(mctx, sr.base, key->datalen);
|
||||
if (key->data == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
key->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -341,42 +341,48 @@ tostruct_keydata(ARGS_TOSTRUCT) {
|
|||
|
||||
/* Refresh timer */
|
||||
if (sr.length < 4) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
/* Not KEYDATA */
|
||||
return (ISC_R_NOTIMPLEMENTED);
|
||||
}
|
||||
keydata->refresh = uint32_fromregion(&sr);
|
||||
isc_region_consume(&sr, 4);
|
||||
|
||||
/* Add hold-down */
|
||||
if (sr.length < 4) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
/* Not KEYDATA */
|
||||
return (ISC_R_NOTIMPLEMENTED);
|
||||
}
|
||||
keydata->addhd = uint32_fromregion(&sr);
|
||||
isc_region_consume(&sr, 4);
|
||||
|
||||
/* Remove hold-down */
|
||||
if (sr.length < 4) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
/* Not KEYDATA */
|
||||
return (ISC_R_NOTIMPLEMENTED);
|
||||
}
|
||||
keydata->removehd = uint32_fromregion(&sr);
|
||||
isc_region_consume(&sr, 4);
|
||||
|
||||
/* Flags */
|
||||
if (sr.length < 2) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
/* Not KEYDATA */
|
||||
return (ISC_R_NOTIMPLEMENTED);
|
||||
}
|
||||
keydata->flags = uint16_fromregion(&sr);
|
||||
isc_region_consume(&sr, 2);
|
||||
|
||||
/* Protocol */
|
||||
if (sr.length < 1) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
/* Not KEYDATA */
|
||||
return (ISC_R_NOTIMPLEMENTED);
|
||||
}
|
||||
keydata->protocol = uint8_fromregion(&sr);
|
||||
isc_region_consume(&sr, 1);
|
||||
|
||||
/* Algorithm */
|
||||
if (sr.length < 1) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
/* Not KEYDATA */
|
||||
return (ISC_R_NOTIMPLEMENTED);
|
||||
}
|
||||
keydata->algorithm = uint8_fromregion(&sr);
|
||||
isc_region_consume(&sr, 1);
|
||||
|
|
@ -384,10 +390,6 @@ tostruct_keydata(ARGS_TOSTRUCT) {
|
|||
/* Data */
|
||||
keydata->datalen = sr.length;
|
||||
keydata->data = mem_maybedup(mctx, sr.base, keydata->datalen);
|
||||
if (keydata->data == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
keydata->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -521,27 +521,18 @@ tostruct_naptr(ARGS_TOSTRUCT) {
|
|||
isc_region_consume(&r, 1);
|
||||
INSIST(naptr->flags_len <= r.length);
|
||||
naptr->flags = mem_maybedup(mctx, r.base, naptr->flags_len);
|
||||
if (naptr->flags == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
isc_region_consume(&r, naptr->flags_len);
|
||||
|
||||
naptr->service_len = uint8_fromregion(&r);
|
||||
isc_region_consume(&r, 1);
|
||||
INSIST(naptr->service_len <= r.length);
|
||||
naptr->service = mem_maybedup(mctx, r.base, naptr->service_len);
|
||||
if (naptr->service == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
isc_region_consume(&r, naptr->service_len);
|
||||
|
||||
naptr->regexp_len = uint8_fromregion(&r);
|
||||
isc_region_consume(&r, 1);
|
||||
INSIST(naptr->regexp_len <= r.length);
|
||||
naptr->regexp = mem_maybedup(mctx, r.base, naptr->regexp_len);
|
||||
if (naptr->regexp == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
isc_region_consume(&r, naptr->regexp_len);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
|
|
@ -550,18 +541,6 @@ tostruct_naptr(ARGS_TOSTRUCT) {
|
|||
name_duporclone(&name, mctx, &naptr->replacement);
|
||||
naptr->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
if (mctx != NULL && naptr->flags != NULL) {
|
||||
isc_mem_free(mctx, naptr->flags);
|
||||
}
|
||||
if (mctx != NULL && naptr->service != NULL) {
|
||||
isc_mem_free(mctx, naptr->service);
|
||||
}
|
||||
if (mctx != NULL && naptr->regexp != NULL) {
|
||||
isc_mem_free(mctx, naptr->regexp);
|
||||
}
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
|
|||
|
|
@ -306,34 +306,17 @@ tostruct_nsec3(ARGS_TOSTRUCT) {
|
|||
nsec3->salt_length = uint8_consume_fromregion(®ion);
|
||||
INSIST(nsec3->salt_length <= region.length);
|
||||
nsec3->salt = mem_maybedup(mctx, region.base, nsec3->salt_length);
|
||||
if (nsec3->salt == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
isc_region_consume(®ion, nsec3->salt_length);
|
||||
|
||||
nsec3->next_length = uint8_consume_fromregion(®ion);
|
||||
INSIST(nsec3->next_length <= region.length);
|
||||
nsec3->next = mem_maybedup(mctx, region.base, nsec3->next_length);
|
||||
if (nsec3->next == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
isc_region_consume(®ion, nsec3->next_length);
|
||||
|
||||
nsec3->len = region.length;
|
||||
nsec3->typebits = mem_maybedup(mctx, region.base, region.length);
|
||||
if (nsec3->typebits == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
nsec3->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
if (nsec3->next != NULL) {
|
||||
isc_mem_free(mctx, nsec3->next);
|
||||
}
|
||||
isc_mem_free(mctx, nsec3->salt);
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
|
|||
|
|
@ -243,9 +243,6 @@ tostruct_nsec3param(ARGS_TOSTRUCT) {
|
|||
INSIST(nsec3param->salt_length == region.length);
|
||||
nsec3param->salt = mem_maybedup(mctx, region.base,
|
||||
nsec3param->salt_length);
|
||||
if (nsec3param->salt == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
isc_region_consume(®ion, nsec3param->salt_length);
|
||||
|
||||
nsec3param->mctx = mctx;
|
||||
|
|
|
|||
|
|
@ -178,18 +178,8 @@ tostruct_nsec(ARGS_TOSTRUCT) {
|
|||
|
||||
nsec->len = region.length;
|
||||
nsec->typebits = mem_maybedup(mctx, region.base, region.length);
|
||||
if (nsec->typebits == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
nsec->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
if (mctx != NULL) {
|
||||
dns_name_free(&nsec->next, mctx);
|
||||
}
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
|
|||
|
|
@ -108,10 +108,6 @@ tostruct_null(ARGS_TOSTRUCT) {
|
|||
dns_rdata_toregion(rdata, &r);
|
||||
null->length = r.length;
|
||||
null->data = mem_maybedup(mctx, r.base, r.length);
|
||||
if (null->data == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
null->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -257,18 +257,8 @@ tostruct_nxt(ARGS_TOSTRUCT) {
|
|||
|
||||
nxt->len = region.length;
|
||||
nxt->typebits = mem_maybedup(mctx, region.base, region.length);
|
||||
if (nxt->typebits == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
nxt->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
if (mctx != NULL) {
|
||||
dns_name_free(&nxt->next, mctx);
|
||||
}
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
|
|||
|
|
@ -156,15 +156,8 @@ tostruct_openpgpkey(ARGS_TOSTRUCT) {
|
|||
*/
|
||||
sig->length = sr.length;
|
||||
sig->keyring = mem_maybedup(mctx, sr.base, sig->length);
|
||||
if (sig->keyring == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
sig->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
|
|||
|
|
@ -330,10 +330,6 @@ tostruct_opt(ARGS_TOSTRUCT) {
|
|||
dns_rdata_toregion(rdata, &r);
|
||||
opt->length = r.length;
|
||||
opt->options = mem_maybedup(mctx, r.base, r.length);
|
||||
if (opt->options == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
opt->offset = 0;
|
||||
opt->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -501,18 +501,8 @@ tostruct_rrsig(ARGS_TOSTRUCT) {
|
|||
*/
|
||||
sig->siglen = sr.length;
|
||||
sig->signature = mem_maybedup(mctx, sr.base, sig->siglen);
|
||||
if (sig->signature == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
sig->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
if (mctx != NULL) {
|
||||
dns_name_free(&sig->signer, mctx);
|
||||
}
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
|
|||
|
|
@ -493,18 +493,8 @@ tostruct_sig(ARGS_TOSTRUCT) {
|
|||
*/
|
||||
sig->siglen = sr.length;
|
||||
sig->signature = mem_maybedup(mctx, sr.base, sig->siglen);
|
||||
if (sig->signature == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
sig->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
if (mctx != NULL) {
|
||||
dns_name_free(&sig->signer, mctx);
|
||||
}
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
|
|||
|
|
@ -191,33 +191,20 @@ tostruct_sink(ARGS_TOSTRUCT) {
|
|||
dns_rdata_toregion(rdata, &sr);
|
||||
|
||||
/* Meaning */
|
||||
if (sr.length < 1) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
}
|
||||
sink->meaning = uint8_fromregion(&sr);
|
||||
isc_region_consume(&sr, 1);
|
||||
|
||||
/* Coding */
|
||||
if (sr.length < 1) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
}
|
||||
sink->coding = uint8_fromregion(&sr);
|
||||
isc_region_consume(&sr, 1);
|
||||
|
||||
/* Subcoding */
|
||||
if (sr.length < 1) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
}
|
||||
sink->subcoding = uint8_fromregion(&sr);
|
||||
isc_region_consume(&sr, 1);
|
||||
|
||||
/* Data */
|
||||
sink->datalen = sr.length;
|
||||
sink->data = mem_maybedup(mctx, sr.base, sink->datalen);
|
||||
if (sink->data == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
sink->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,10 +218,6 @@ tostruct_sshfp(ARGS_TOSTRUCT) {
|
|||
sshfp->length = region.length;
|
||||
|
||||
sshfp->digest = mem_maybedup(mctx, region.base, region.length);
|
||||
if (sshfp->digest == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
sshfp->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -474,9 +474,6 @@ tostruct_tkey(ARGS_TOSTRUCT) {
|
|||
*/
|
||||
INSIST(tkey->keylen + 2U <= sr.length);
|
||||
tkey->key = mem_maybedup(mctx, sr.base, tkey->keylen);
|
||||
if (tkey->key == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
isc_region_consume(&sr, tkey->keylen);
|
||||
|
||||
/*
|
||||
|
|
@ -490,21 +487,8 @@ tostruct_tkey(ARGS_TOSTRUCT) {
|
|||
*/
|
||||
INSIST(tkey->otherlen <= sr.length);
|
||||
tkey->other = mem_maybedup(mctx, sr.base, tkey->otherlen);
|
||||
if (tkey->other == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
tkey->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
if (mctx != NULL) {
|
||||
dns_name_free(&tkey->algorithm, mctx);
|
||||
}
|
||||
if (mctx != NULL && tkey->key != NULL) {
|
||||
isc_mem_free(mctx, tkey->key);
|
||||
}
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
|
|||
|
|
@ -231,10 +231,6 @@ generic_tostruct_tlsa(ARGS_TOSTRUCT) {
|
|||
tlsa->length = region.length;
|
||||
|
||||
tlsa->data = mem_maybedup(mctx, region.base, region.length);
|
||||
if (tlsa->data == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
tlsa->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,10 +172,6 @@ generic_tostruct_txt(ARGS_TOSTRUCT) {
|
|||
dns_rdata_toregion(rdata, &r);
|
||||
txt->txt_len = r.length;
|
||||
txt->txt = mem_maybedup(mctx, r.base, r.length);
|
||||
if (txt->txt == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
txt->offset = 0;
|
||||
txt->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ tostruct_uri(ARGS_TOSTRUCT) {
|
|||
|
||||
REQUIRE(rdata->type == dns_rdatatype_uri);
|
||||
REQUIRE(uri != NULL);
|
||||
REQUIRE(rdata->length != 0);
|
||||
REQUIRE(rdata->length >= 4);
|
||||
|
||||
uri->common.rdclass = rdata->rdclass;
|
||||
uri->common.rdtype = rdata->type;
|
||||
|
|
@ -220,18 +220,12 @@ tostruct_uri(ARGS_TOSTRUCT) {
|
|||
/*
|
||||
* Priority
|
||||
*/
|
||||
if (sr.length < 2) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
}
|
||||
uri->priority = uint16_fromregion(&sr);
|
||||
isc_region_consume(&sr, 2);
|
||||
|
||||
/*
|
||||
* Weight
|
||||
*/
|
||||
if (sr.length < 2) {
|
||||
return (ISC_R_UNEXPECTEDEND);
|
||||
}
|
||||
uri->weight = uint16_fromregion(&sr);
|
||||
isc_region_consume(&sr, 2);
|
||||
|
||||
|
|
@ -240,10 +234,6 @@ tostruct_uri(ARGS_TOSTRUCT) {
|
|||
*/
|
||||
uri->tgt_len = sr.length;
|
||||
uri->target = mem_maybedup(mctx, sr.base, sr.length);
|
||||
if (uri->target == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
uri->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,10 +154,6 @@ tostruct_x25(ARGS_TOSTRUCT) {
|
|||
x25->x25_len = uint8_fromregion(&r);
|
||||
isc_region_consume(&r, 1);
|
||||
x25->x25 = mem_maybedup(mctx, r.base, x25->x25_len);
|
||||
if (x25->x25 == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
x25->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -272,10 +272,6 @@ tostruct_zonemd(ARGS_TOSTRUCT) {
|
|||
zonemd->length = region.length;
|
||||
|
||||
zonemd->digest = mem_maybedup(mctx, region.base, region.length);
|
||||
if (zonemd->digest == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
zonemd->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -295,10 +295,6 @@ tostruct_in_apl(ARGS_TOSTRUCT) {
|
|||
dns_rdata_toregion(rdata, &r);
|
||||
apl->apl_len = r.length;
|
||||
apl->apl = mem_maybedup(mctx, r.base, r.length);
|
||||
if (apl->apl == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
apl->offset = 0;
|
||||
apl->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -234,10 +234,6 @@ tostruct_in_atma(ARGS_TOSTRUCT) {
|
|||
isc_region_consume(&r, 1);
|
||||
atma->atma_len = r.length;
|
||||
atma->atma = mem_maybedup(mctx, r.base, r.length);
|
||||
if (atma->atma == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
atma->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,10 +152,6 @@ tostruct_in_dhcid(ARGS_TOSTRUCT) {
|
|||
dns_rdata_toregion(rdata, ®ion);
|
||||
|
||||
dhcid->dhcid = mem_maybedup(mctx, region.base, region.length);
|
||||
if (dhcid->dhcid == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
dhcid->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,10 +141,6 @@ tostruct_in_eid(ARGS_TOSTRUCT) {
|
|||
dns_rdata_toregion(rdata, &r);
|
||||
eid->eid_len = r.length;
|
||||
eid->eid = mem_maybedup(mctx, r.base, r.length);
|
||||
if (eid->eid == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
eid->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,10 +141,6 @@ tostruct_in_nimloc(ARGS_TOSTRUCT) {
|
|||
dns_rdata_toregion(rdata, &r);
|
||||
nimloc->nimloc_len = r.length;
|
||||
nimloc->nimloc = mem_maybedup(mctx, r.base, r.length);
|
||||
if (nimloc->nimloc == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
nimloc->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,10 +176,6 @@ tostruct_in_nsap(ARGS_TOSTRUCT) {
|
|||
dns_rdata_toregion(rdata, &r);
|
||||
nsap->nsap_len = r.length;
|
||||
nsap->nsap = mem_maybedup(mctx, r.base, r.length);
|
||||
if (nsap->nsap == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
nsap->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1014,13 +1014,6 @@ generic_tostruct_in_svcb(ARGS_TOSTRUCT) {
|
|||
svcb->svclen = region.length;
|
||||
svcb->svc = mem_maybedup(mctx, region.base, region.length);
|
||||
|
||||
if (svcb->svc == NULL) {
|
||||
if (mctx != NULL) {
|
||||
dns_name_free(&svcb->svcdomain, svcb->mctx);
|
||||
}
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
svcb->offset = 0;
|
||||
svcb->mctx = mctx;
|
||||
|
||||
|
|
|
|||
|
|
@ -323,9 +323,6 @@ tostruct_in_wks(ARGS_TOSTRUCT) {
|
|||
isc_region_consume(®ion, 1);
|
||||
wks->map_len = region.length;
|
||||
wks->map = mem_maybedup(mctx, region.base, region.length);
|
||||
if (wks->map == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
wks->mctx = mctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4362,7 +4362,7 @@ load_secroots(dns_zone_t *zone, dns_name_t *name, dns_rdataset_t *rdataset) {
|
|||
|
||||
/* Convert rdata to keydata. */
|
||||
result = dns_rdata_tostruct(&rdata, &keydata, NULL);
|
||||
if (result == ISC_R_UNEXPECTEDEND) {
|
||||
if (result == ISC_R_NOTIMPLEMENTED) {
|
||||
continue;
|
||||
}
|
||||
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
||||
|
|
|
|||
Loading…
Reference in a new issue