mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 05:57:52 +00:00
Do not return ISC_R_UNEXPECTEDEND
All rdata passed to dns_rdata_tostruct is supposed to be well formed, assert if it isn't.
This commit is contained in:
parent
bbaade23eb
commit
48039fa25e
@ -507,27 +507,19 @@ tostruct_caa(ARGS_TOSTRUCT) {
|
|||||||
/*
|
/*
|
||||||
* Flags
|
* Flags
|
||||||
*/
|
*/
|
||||||
if (sr.length < 1) {
|
|
||||||
return (ISC_R_UNEXPECTEDEND);
|
|
||||||
}
|
|
||||||
caa->flags = uint8_fromregion(&sr);
|
caa->flags = uint8_fromregion(&sr);
|
||||||
isc_region_consume(&sr, 1);
|
isc_region_consume(&sr, 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tag length
|
* Tag length
|
||||||
*/
|
*/
|
||||||
if (sr.length < 1) {
|
|
||||||
return (ISC_R_UNEXPECTEDEND);
|
|
||||||
}
|
|
||||||
caa->tag_len = uint8_fromregion(&sr);
|
caa->tag_len = uint8_fromregion(&sr);
|
||||||
isc_region_consume(&sr, 1);
|
isc_region_consume(&sr, 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tag
|
* Tag
|
||||||
*/
|
*/
|
||||||
if (sr.length < caa->tag_len) {
|
INSIST(sr.length >= caa->tag_len);
|
||||||
return (ISC_R_UNEXPECTEDEND);
|
|
||||||
}
|
|
||||||
caa->tag = mem_maybedup(mctx, sr.base, caa->tag_len);
|
caa->tag = mem_maybedup(mctx, sr.base, caa->tag_len);
|
||||||
isc_region_consume(&sr, caa->tag_len);
|
isc_region_consume(&sr, caa->tag_len);
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ tostruct_doa(ARGS_TOSTRUCT) {
|
|||||||
REQUIRE(rdata != NULL);
|
REQUIRE(rdata != NULL);
|
||||||
REQUIRE(rdata->type == dns_rdatatype_doa);
|
REQUIRE(rdata->type == dns_rdatatype_doa);
|
||||||
REQUIRE(doa != NULL);
|
REQUIRE(doa != NULL);
|
||||||
REQUIRE(rdata->length != 0);
|
REQUIRE(rdata->length >= 10);
|
||||||
|
|
||||||
doa->common.rdclass = rdata->rdclass;
|
doa->common.rdclass = rdata->rdclass;
|
||||||
doa->common.rdtype = rdata->type;
|
doa->common.rdtype = rdata->type;
|
||||||
@ -224,36 +224,24 @@ tostruct_doa(ARGS_TOSTRUCT) {
|
|||||||
/*
|
/*
|
||||||
* DOA-ENTERPRISE
|
* DOA-ENTERPRISE
|
||||||
*/
|
*/
|
||||||
if (region.length < 4) {
|
|
||||||
return (ISC_R_UNEXPECTEDEND);
|
|
||||||
}
|
|
||||||
doa->enterprise = uint32_fromregion(®ion);
|
doa->enterprise = uint32_fromregion(®ion);
|
||||||
isc_region_consume(®ion, 4);
|
isc_region_consume(®ion, 4);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DOA-TYPE
|
* DOA-TYPE
|
||||||
*/
|
*/
|
||||||
if (region.length < 4) {
|
|
||||||
return (ISC_R_UNEXPECTEDEND);
|
|
||||||
}
|
|
||||||
doa->type = uint32_fromregion(®ion);
|
doa->type = uint32_fromregion(®ion);
|
||||||
isc_region_consume(®ion, 4);
|
isc_region_consume(®ion, 4);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DOA-LOCATION
|
* DOA-LOCATION
|
||||||
*/
|
*/
|
||||||
if (region.length < 1) {
|
|
||||||
return (ISC_R_UNEXPECTEDEND);
|
|
||||||
}
|
|
||||||
doa->location = uint8_fromregion(®ion);
|
doa->location = uint8_fromregion(®ion);
|
||||||
isc_region_consume(®ion, 1);
|
isc_region_consume(®ion, 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DOA-MEDIA-TYPE
|
* DOA-MEDIA-TYPE
|
||||||
*/
|
*/
|
||||||
if (region.length < 1) {
|
|
||||||
return (ISC_R_UNEXPECTEDEND);
|
|
||||||
}
|
|
||||||
doa->mediatype_len = uint8_fromregion(®ion);
|
doa->mediatype_len = uint8_fromregion(®ion);
|
||||||
isc_region_consume(®ion, 1);
|
isc_region_consume(®ion, 1);
|
||||||
INSIST(doa->mediatype_len <= region.length);
|
INSIST(doa->mediatype_len <= region.length);
|
||||||
|
@ -353,10 +353,6 @@ tostruct_ipseckey(ARGS_TOSTRUCT) {
|
|||||||
REQUIRE(ipseckey != NULL);
|
REQUIRE(ipseckey != NULL);
|
||||||
REQUIRE(rdata->length >= 3);
|
REQUIRE(rdata->length >= 3);
|
||||||
|
|
||||||
if (rdata->data[1] > 3U) {
|
|
||||||
return (ISC_R_NOTIMPLEMENTED);
|
|
||||||
}
|
|
||||||
|
|
||||||
ipseckey->common.rdclass = rdata->rdclass;
|
ipseckey->common.rdclass = rdata->rdclass;
|
||||||
ipseckey->common.rdtype = rdata->type;
|
ipseckey->common.rdtype = rdata->type;
|
||||||
ISC_LINK_INIT(&ipseckey->common, link);
|
ISC_LINK_INIT(&ipseckey->common, link);
|
||||||
@ -384,6 +380,7 @@ tostruct_ipseckey(ARGS_TOSTRUCT) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
INSIST(region.length >= 16U);
|
||||||
memmove(ipseckey->in6_addr.s6_addr, region.base, 16);
|
memmove(ipseckey->in6_addr.s6_addr, region.base, 16);
|
||||||
isc_region_consume(®ion, 16);
|
isc_region_consume(®ion, 16);
|
||||||
break;
|
break;
|
||||||
|
@ -322,7 +322,7 @@ generic_tostruct_key(ARGS_TOSTRUCT) {
|
|||||||
isc_region_t sr;
|
isc_region_t sr;
|
||||||
|
|
||||||
REQUIRE(key != NULL);
|
REQUIRE(key != NULL);
|
||||||
REQUIRE(rdata->length != 0);
|
REQUIRE(rdata->length >= 4U);
|
||||||
|
|
||||||
REQUIRE(key != NULL);
|
REQUIRE(key != NULL);
|
||||||
REQUIRE(key->common.rdclass == rdata->rdclass);
|
REQUIRE(key->common.rdclass == rdata->rdclass);
|
||||||
@ -332,23 +332,14 @@ generic_tostruct_key(ARGS_TOSTRUCT) {
|
|||||||
dns_rdata_toregion(rdata, &sr);
|
dns_rdata_toregion(rdata, &sr);
|
||||||
|
|
||||||
/* Flags */
|
/* Flags */
|
||||||
if (sr.length < 2) {
|
|
||||||
return (ISC_R_UNEXPECTEDEND);
|
|
||||||
}
|
|
||||||
key->flags = uint16_fromregion(&sr);
|
key->flags = uint16_fromregion(&sr);
|
||||||
isc_region_consume(&sr, 2);
|
isc_region_consume(&sr, 2);
|
||||||
|
|
||||||
/* Protocol */
|
/* Protocol */
|
||||||
if (sr.length < 1) {
|
|
||||||
return (ISC_R_UNEXPECTEDEND);
|
|
||||||
}
|
|
||||||
key->protocol = uint8_fromregion(&sr);
|
key->protocol = uint8_fromregion(&sr);
|
||||||
isc_region_consume(&sr, 1);
|
isc_region_consume(&sr, 1);
|
||||||
|
|
||||||
/* Algorithm */
|
/* Algorithm */
|
||||||
if (sr.length < 1) {
|
|
||||||
return (ISC_R_UNEXPECTEDEND);
|
|
||||||
}
|
|
||||||
key->algorithm = uint8_fromregion(&sr);
|
key->algorithm = uint8_fromregion(&sr);
|
||||||
isc_region_consume(&sr, 1);
|
isc_region_consume(&sr, 1);
|
||||||
|
|
||||||
|
@ -191,23 +191,14 @@ tostruct_sink(ARGS_TOSTRUCT) {
|
|||||||
dns_rdata_toregion(rdata, &sr);
|
dns_rdata_toregion(rdata, &sr);
|
||||||
|
|
||||||
/* Meaning */
|
/* Meaning */
|
||||||
if (sr.length < 1) {
|
|
||||||
return (ISC_R_UNEXPECTEDEND);
|
|
||||||
}
|
|
||||||
sink->meaning = uint8_fromregion(&sr);
|
sink->meaning = uint8_fromregion(&sr);
|
||||||
isc_region_consume(&sr, 1);
|
isc_region_consume(&sr, 1);
|
||||||
|
|
||||||
/* Coding */
|
/* Coding */
|
||||||
if (sr.length < 1) {
|
|
||||||
return (ISC_R_UNEXPECTEDEND);
|
|
||||||
}
|
|
||||||
sink->coding = uint8_fromregion(&sr);
|
sink->coding = uint8_fromregion(&sr);
|
||||||
isc_region_consume(&sr, 1);
|
isc_region_consume(&sr, 1);
|
||||||
|
|
||||||
/* Subcoding */
|
/* Subcoding */
|
||||||
if (sr.length < 1) {
|
|
||||||
return (ISC_R_UNEXPECTEDEND);
|
|
||||||
}
|
|
||||||
sink->subcoding = uint8_fromregion(&sr);
|
sink->subcoding = uint8_fromregion(&sr);
|
||||||
isc_region_consume(&sr, 1);
|
isc_region_consume(&sr, 1);
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ tostruct_uri(ARGS_TOSTRUCT) {
|
|||||||
|
|
||||||
REQUIRE(rdata->type == dns_rdatatype_uri);
|
REQUIRE(rdata->type == dns_rdatatype_uri);
|
||||||
REQUIRE(uri != NULL);
|
REQUIRE(uri != NULL);
|
||||||
REQUIRE(rdata->length != 0);
|
REQUIRE(rdata->length >= 4);
|
||||||
|
|
||||||
uri->common.rdclass = rdata->rdclass;
|
uri->common.rdclass = rdata->rdclass;
|
||||||
uri->common.rdtype = rdata->type;
|
uri->common.rdtype = rdata->type;
|
||||||
@ -220,18 +220,12 @@ tostruct_uri(ARGS_TOSTRUCT) {
|
|||||||
/*
|
/*
|
||||||
* Priority
|
* Priority
|
||||||
*/
|
*/
|
||||||
if (sr.length < 2) {
|
|
||||||
return (ISC_R_UNEXPECTEDEND);
|
|
||||||
}
|
|
||||||
uri->priority = uint16_fromregion(&sr);
|
uri->priority = uint16_fromregion(&sr);
|
||||||
isc_region_consume(&sr, 2);
|
isc_region_consume(&sr, 2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Weight
|
* Weight
|
||||||
*/
|
*/
|
||||||
if (sr.length < 2) {
|
|
||||||
return (ISC_R_UNEXPECTEDEND);
|
|
||||||
}
|
|
||||||
uri->weight = uint16_fromregion(&sr);
|
uri->weight = uint16_fromregion(&sr);
|
||||||
isc_region_consume(&sr, 2);
|
isc_region_consume(&sr, 2);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user