diff --git a/lib/dns/rdata/any_255/tsig_250.c b/lib/dns/rdata/any_255/tsig_250.c index 6616eb2a7b..2de6a8f528 100644 --- a/lib/dns/rdata/any_255/tsig_250.c +++ b/lib/dns/rdata/any_255/tsig_250.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: tsig_250.c,v 1.50 2001/03/16 22:52:32 bwelling Exp $ */ +/* $Id: tsig_250.c,v 1.51 2001/06/21 04:00:28 marka Exp $ */ /* Reviewed: Thu Mar 16 13:39:43 PST 2000 by gson */ @@ -476,13 +476,10 @@ tostruct_any_tsig(ARGS_TOSTRUCT) { * Signature. */ INSIST(sr.length >= tsig->siglen); - if (tsig->siglen != 0) { - tsig->signature = mem_maybedup(mctx, sr.base, tsig->siglen); - if (tsig->signature == NULL) - goto cleanup; - isc_region_consume(&sr, tsig->siglen); - } else - tsig->signature = NULL; + tsig->signature = mem_maybedup(mctx, sr.base, tsig->siglen); + if (tsig->signature == NULL) + goto cleanup; + isc_region_consume(&sr, tsig->siglen); /* * Original ID. @@ -506,12 +503,9 @@ tostruct_any_tsig(ARGS_TOSTRUCT) { * Other. */ INSIST(sr.length == tsig->otherlen); - if (tsig->otherlen != 0) { - tsig->other = mem_maybedup(mctx, sr.base, tsig->otherlen); - if (tsig->other == NULL) - goto cleanup; - } else - tsig->other = NULL; + tsig->other = mem_maybedup(mctx, sr.base, tsig->otherlen); + if (tsig->other == NULL) + goto cleanup; tsig->mctx = mctx; return (ISC_R_SUCCESS); diff --git a/lib/dns/rdata/generic/cert_37.c b/lib/dns/rdata/generic/cert_37.c index 9f9cacdb30..3e0cab84cb 100644 --- a/lib/dns/rdata/generic/cert_37.c +++ b/lib/dns/rdata/generic/cert_37.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: cert_37.c,v 1.38 2001/03/16 22:52:35 bwelling Exp $ */ +/* $Id: cert_37.c,v 1.39 2001/06/21 04:00:30 marka Exp $ */ /* Reviewed: Wed Mar 15 21:14:32 EST 2000 by tale */ @@ -205,13 +205,9 @@ tostruct_cert(ARGS_TOSTRUCT) { isc_region_consume(®ion, 1); cert->length = region.length; - if (cert->length > 0) { - cert->certificate = mem_maybedup(mctx, region.base, - region.length); - if (cert->certificate == NULL) - return (ISC_R_NOMEMORY); - } else - cert->certificate = NULL; + cert->certificate = mem_maybedup(mctx, region.base, region.length); + if (cert->certificate == NULL) + return (ISC_R_NOMEMORY); cert->mctx = mctx; return (ISC_R_SUCCESS); diff --git a/lib/dns/rdata/generic/gpos_27.c b/lib/dns/rdata/generic/gpos_27.c index f44cc53354..ac8efb19ab 100644 --- a/lib/dns/rdata/generic/gpos_27.c +++ b/lib/dns/rdata/generic/gpos_27.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: gpos_27.c,v 1.30 2001/03/16 22:52:38 bwelling Exp $ */ +/* $Id: gpos_27.c,v 1.31 2001/06/21 04:00:31 marka Exp $ */ /* reviewed: Wed Mar 15 16:48:45 PST 2000 by brister */ @@ -147,25 +147,17 @@ tostruct_gpos(ARGS_TOSTRUCT) { dns_rdata_toregion(rdata, ®ion); gpos->long_len = uint8_fromregion(®ion); isc_region_consume(®ion, 1); - if (gpos->long_len != 0) { - 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); - } else - gpos->longitude = NULL; + 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); - if (gpos->lat_len > 0) { - gpos->latitude = - mem_maybedup(mctx, region.base, gpos->lat_len); - if (gpos->latitude == NULL) - goto cleanup_longitude; - isc_region_consume(®ion, gpos->lat_len); - } else - gpos->latitude = NULL; + 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); diff --git a/lib/dns/rdata/generic/hinfo_13.c b/lib/dns/rdata/generic/hinfo_13.c index 307a22bb3f..fd02b40bcb 100644 --- a/lib/dns/rdata/generic/hinfo_13.c +++ b/lib/dns/rdata/generic/hinfo_13.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: hinfo_13.c,v 1.35 2001/03/16 22:52:39 bwelling Exp $ */ +/* $Id: hinfo_13.c,v 1.36 2001/06/21 04:00:32 marka Exp $ */ /* * Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley. @@ -137,22 +137,17 @@ tostruct_hinfo(ARGS_TOSTRUCT) { dns_rdata_toregion(rdata, ®ion); hinfo->cpu_len = uint8_fromregion(®ion); isc_region_consume(®ion, 1); - if (hinfo->cpu_len > 0) { - 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); - } else - hinfo->cpu = NULL; + 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); - if (hinfo->os_len > 0) { - hinfo->os = mem_maybedup(mctx, region.base, hinfo->os_len); - if (hinfo->os == NULL) - goto cleanup; - } else - hinfo->os = NULL; + hinfo->os = mem_maybedup(mctx, region.base, hinfo->os_len); + if (hinfo->os == NULL) + goto cleanup; + hinfo->mctx = mctx; return (ISC_R_SUCCESS); diff --git a/lib/dns/rdata/generic/isdn_20.c b/lib/dns/rdata/generic/isdn_20.c index e7aa60ec29..6ea3554930 100644 --- a/lib/dns/rdata/generic/isdn_20.c +++ b/lib/dns/rdata/generic/isdn_20.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: isdn_20.c,v 1.28 2001/03/16 22:52:41 bwelling Exp $ */ +/* $Id: isdn_20.c,v 1.29 2001/06/21 04:00:33 marka Exp $ */ /* Reviewed: Wed Mar 15 16:53:11 PST 2000 by bwelling */ @@ -147,23 +147,16 @@ tostruct_isdn(ARGS_TOSTRUCT) { isdn->isdn_len = uint8_fromregion(&r); isc_region_consume(&r, 1); - if (isdn->isdn_len > 0) { - 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); - } else - isdn->isdn = NULL; + 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); isdn->subaddress_len = uint8_fromregion(&r); isc_region_consume(&r, 1); - if (isdn->subaddress_len > 0) { - isdn->subaddress = mem_maybedup(mctx, r.base, - isdn->subaddress_len); - if (isdn->subaddress == NULL) - goto cleanup; - } else - isdn->subaddress = NULL; + isdn->subaddress = mem_maybedup(mctx, r.base, isdn->subaddress_len); + if (isdn->subaddress == NULL) + goto cleanup; isdn->mctx = mctx; return (ISC_R_SUCCESS); diff --git a/lib/dns/rdata/generic/key_25.c b/lib/dns/rdata/generic/key_25.c index e5913cc830..efe30b2591 100644 --- a/lib/dns/rdata/generic/key_25.c +++ b/lib/dns/rdata/generic/key_25.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: key_25.c,v 1.39 2001/03/28 02:57:26 bwelling Exp $ */ +/* $Id: key_25.c,v 1.40 2001/06/21 04:00:34 marka Exp $ */ /* * Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley. @@ -238,12 +238,9 @@ tostruct_key(ARGS_TOSTRUCT) { /* Data */ key->datalen = sr.length; - if (key->datalen > 0) { - key->data = mem_maybedup(mctx, sr.base, key->datalen); - if (key->data == NULL) - return (ISC_R_NOMEMORY); - } else - key->data = NULL; + key->data = mem_maybedup(mctx, sr.base, key->datalen); + if (key->data == NULL) + return (ISC_R_NOMEMORY); key->mctx = mctx; return (ISC_R_SUCCESS); diff --git a/lib/dns/rdata/generic/null_10.c b/lib/dns/rdata/generic/null_10.c index 1a95f4e6f8..36a8d5fac9 100644 --- a/lib/dns/rdata/generic/null_10.c +++ b/lib/dns/rdata/generic/null_10.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: null_10.c,v 1.33 2001/06/20 17:43:31 gson Exp $ */ +/* $Id: null_10.c,v 1.34 2001/06/21 04:00:36 marka Exp $ */ /* Reviewed: Thu Mar 16 13:57:50 PST 2000 by explorer */ @@ -96,8 +96,7 @@ fromstruct_null(ARGS_FROMSTRUCT) { REQUIRE(source != NULL); REQUIRE(null->common.rdtype == type); REQUIRE(null->common.rdclass == rdclass); - REQUIRE((null->data != NULL && null->length != 0) || - (null->data == NULL && null->length == 0)); + REQUIRE(null->data != NULL || null->length == 0); UNUSED(type); UNUSED(rdclass); @@ -119,12 +118,9 @@ tostruct_null(ARGS_TOSTRUCT) { dns_rdata_toregion(rdata, &r); null->length = r.length; - if (null->length != 0) { - null->data = mem_maybedup(mctx, r.base, r.length); - if (null->data == NULL) - return (ISC_R_NOMEMORY); - } else - null->data = NULL; + null->data = mem_maybedup(mctx, r.base, r.length); + if (null->data == NULL) + return (ISC_R_NOMEMORY); null->mctx = mctx; return (ISC_R_SUCCESS); diff --git a/lib/dns/rdata/generic/opt_41.c b/lib/dns/rdata/generic/opt_41.c index 345a3c3141..f2762b5175 100644 --- a/lib/dns/rdata/generic/opt_41.c +++ b/lib/dns/rdata/generic/opt_41.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: opt_41.c,v 1.23 2001/03/16 22:52:57 bwelling Exp $ */ +/* $Id: opt_41.c,v 1.24 2001/06/21 04:00:37 marka Exp $ */ /* Reviewed: Thu Mar 16 14:06:44 PST 2000 by gson */ @@ -166,8 +166,7 @@ fromstruct_opt(ARGS_FROMSTRUCT) { REQUIRE(source != NULL); REQUIRE(opt->common.rdtype == type); REQUIRE(opt->common.rdclass == rdclass); - REQUIRE((opt->options != NULL && opt->length != 0) || - (opt->options == NULL && opt->length == 0)); + REQUIRE(opt->options != NULL || opt->length == 0); UNUSED(type); UNUSED(rdclass); @@ -202,12 +201,9 @@ tostruct_opt(ARGS_TOSTRUCT) { dns_rdata_toregion(rdata, &r); opt->length = r.length; - if (opt->length != 0) { - opt->options = mem_maybedup(mctx, r.base, r.length); - if (opt->options == NULL) - return (ISC_R_NOMEMORY); - } else - opt->options = NULL; + opt->options = mem_maybedup(mctx, r.base, r.length); + if (opt->options == NULL) + return (ISC_R_NOMEMORY); opt->offset = 0; opt->mctx = mctx; diff --git a/lib/dns/rdata/generic/sig_24.c b/lib/dns/rdata/generic/sig_24.c index 7575a09725..bf24f3ad3c 100644 --- a/lib/dns/rdata/generic/sig_24.c +++ b/lib/dns/rdata/generic/sig_24.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: sig_24.c,v 1.52 2001/03/16 22:53:01 bwelling Exp $ */ +/* $Id: sig_24.c,v 1.53 2001/06/21 04:00:38 marka Exp $ */ /* Reviewed: Fri Mar 17 09:05:02 PST 2000 by gson */ @@ -364,8 +364,7 @@ fromstruct_sig(ARGS_FROMSTRUCT) { REQUIRE(source != NULL); REQUIRE(sig->common.rdtype == type); REQUIRE(sig->common.rdclass == rdclass); - REQUIRE((sig->signature != NULL && sig->siglen != 0) || - (sig->signature == NULL && sig->siglen == 0)); + REQUIRE(sig->signature != NULL || sig->siglen == 0); UNUSED(type); UNUSED(rdclass); @@ -484,12 +483,9 @@ tostruct_sig(ARGS_TOSTRUCT) { * Signature. */ sig->siglen = sr.length; - if (sig->siglen > 0) { - sig->signature = mem_maybedup(mctx, sr.base, sig->siglen); - if (sig->signature == NULL) - goto cleanup; - } else - sig->signature = NULL; + sig->signature = mem_maybedup(mctx, sr.base, sig->siglen); + if (sig->signature == NULL) + goto cleanup; sig->mctx = mctx; diff --git a/lib/dns/rdata/generic/tkey_249.c b/lib/dns/rdata/generic/tkey_249.c index b943bb7f0c..7dd78fdf6c 100644 --- a/lib/dns/rdata/generic/tkey_249.c +++ b/lib/dns/rdata/generic/tkey_249.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: tkey_249.c,v 1.46 2001/03/16 22:53:04 bwelling Exp $ */ +/* $Id: tkey_249.c,v 1.47 2001/06/21 04:00:39 marka Exp $ */ /* * Reviewed: Thu Mar 16 17:35:30 PST 2000 by halley. @@ -458,13 +458,10 @@ tostruct_tkey(ARGS_TOSTRUCT) { /* * Key. */ - if (tkey->keylen > 0) { - tkey->key = mem_maybedup(mctx, sr.base, tkey->keylen); - if (tkey->key == NULL) - goto cleanup; - isc_region_consume(&sr, tkey->keylen); - } else - tkey->key = NULL; + tkey->key = mem_maybedup(mctx, sr.base, tkey->keylen); + if (tkey->key == NULL) + goto cleanup; + isc_region_consume(&sr, tkey->keylen); /* * Other size. @@ -475,12 +472,9 @@ tostruct_tkey(ARGS_TOSTRUCT) { /* * Other. */ - if (tkey->otherlen > 0) { - tkey->other = mem_maybedup(mctx, sr.base, tkey->otherlen); - if (tkey->other == NULL) - goto cleanup; - } else - tkey->other = NULL; + tkey->other = mem_maybedup(mctx, sr.base, tkey->otherlen); + if (tkey->other == NULL) + goto cleanup; tkey->mctx = mctx; return (ISC_R_SUCCESS); diff --git a/lib/dns/rdata/generic/txt_16.c b/lib/dns/rdata/generic/txt_16.c index 8135f374d9..8052c2dd2d 100644 --- a/lib/dns/rdata/generic/txt_16.c +++ b/lib/dns/rdata/generic/txt_16.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: txt_16.c,v 1.35 2001/03/16 22:53:05 bwelling Exp $ */ +/* $Id: txt_16.c,v 1.36 2001/06/21 04:00:41 marka Exp $ */ /* Reviewed: Thu Mar 16 15:40:00 PST 2000 by bwelling */ @@ -27,6 +27,7 @@ static inline isc_result_t fromtext_txt(ARGS_FROMTEXT) { isc_token_t token; + int strings; REQUIRE(type == 16); @@ -35,7 +36,8 @@ fromtext_txt(ARGS_FROMTEXT) { UNUSED(origin); UNUSED(downcase); - for(;;) { + strings = 0; + for (;;) { RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring, ISC_TRUE)); @@ -43,10 +45,11 @@ fromtext_txt(ARGS_FROMTEXT) { token.type != isc_tokentype_string) break; RETTOK(txt_fromtext(&token.value.as_textregion, target)); + strings++; } /* Let upper layer handle eol/eof. */ isc_lex_ungettoken(lexer, &token); - return (ISC_R_SUCCESS); + return (strings == 0 ? ISC_R_UNEXPECTEDEND : ISC_R_SUCCESS); } static inline isc_result_t @@ -79,11 +82,11 @@ fromwire_txt(ARGS_FROMWIRE) { UNUSED(rdclass); UNUSED(downcase); - while (!buffer_empty(source)) { + do { result = txt_fromwire(source, target); if (result != ISC_R_SUCCESS) return (result); - } + } while (!buffer_empty(source)); return (ISC_R_SUCCESS); } @@ -128,8 +131,7 @@ fromstruct_txt(ARGS_FROMSTRUCT) { REQUIRE(source != NULL); REQUIRE(txt->common.rdtype == type); REQUIRE(txt->common.rdclass == rdclass); - REQUIRE((txt->txt == NULL && txt->txt_len == 0) || - (txt->txt != NULL && txt->txt_len != 0)); + REQUIRE(txt->txt != NULL && txt->txt_len != 0); UNUSED(type); UNUSED(rdclass); @@ -161,12 +163,9 @@ tostruct_txt(ARGS_TOSTRUCT) { dns_rdata_toregion(rdata, &r); txt->txt_len = r.length; - if (txt->txt_len != 0) { - txt->txt = mem_maybedup(mctx, r.base, r.length); - if (txt->txt == NULL) - return (ISC_R_NOMEMORY); - } else - txt->txt = NULL; + txt->txt = mem_maybedup(mctx, r.base, r.length); + if (txt->txt == NULL) + return (ISC_R_NOMEMORY); txt->offset = 0; txt->mctx = mctx; diff --git a/lib/dns/rdata/generic/unspec_103.c b/lib/dns/rdata/generic/unspec_103.c index 0541fc1aa6..0a9e83246a 100644 --- a/lib/dns/rdata/generic/unspec_103.c +++ b/lib/dns/rdata/generic/unspec_103.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: unspec_103.c,v 1.26 2001/03/16 22:53:06 bwelling Exp $ */ +/* $Id: unspec_103.c,v 1.27 2001/06/21 04:00:42 marka Exp $ */ #ifndef RDATA_GENERIC_UNSPEC_103_C #define RDATA_GENERIC_UNSPEC_103_C @@ -93,8 +93,7 @@ fromstruct_unspec(ARGS_FROMSTRUCT) { REQUIRE(source != NULL); REQUIRE(unspec->common.rdtype == type); REQUIRE(unspec->common.rdclass == rdclass); - REQUIRE((unspec->data != NULL && unspec->datalen != 0) || - (unspec->data == NULL && unspec->datalen == 0)); + REQUIRE(unspec->data != NULL || unspec->datalen == 0); UNUSED(type); UNUSED(rdclass); @@ -116,12 +115,9 @@ tostruct_unspec(ARGS_TOSTRUCT) { dns_rdata_toregion(rdata, &r); unspec->datalen = r.length; - if (unspec->datalen != 0) { - unspec->data = mem_maybedup(mctx, r.base, r.length); - if (unspec->data == NULL) - return (ISC_R_NOMEMORY); - } else - unspec->data = NULL; + unspec->data = mem_maybedup(mctx, r.base, r.length); + if (unspec->data == NULL) + return (ISC_R_NOMEMORY); unspec->mctx = mctx; return (ISC_R_SUCCESS); diff --git a/lib/dns/rdata/generic/x25_19.c b/lib/dns/rdata/generic/x25_19.c index 58e26b79c5..5710154e9d 100644 --- a/lib/dns/rdata/generic/x25_19.c +++ b/lib/dns/rdata/generic/x25_19.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: x25_19.c,v 1.29 2001/03/16 22:53:07 bwelling Exp $ */ +/* $Id: x25_19.c,v 1.30 2001/06/21 04:00:43 marka Exp $ */ /* Reviewed: Thu Mar 16 16:15:57 PST 2000 by bwelling */ @@ -114,12 +114,14 @@ fromstruct_x25(ARGS_FROMSTRUCT) { REQUIRE(source != NULL); REQUIRE(x25->common.rdtype == type); REQUIRE(x25->common.rdclass == rdclass); - REQUIRE((x25->x25 == NULL && x25->x25_len == 0) || - (x25->x25 != NULL && x25->x25_len != 0)); + REQUIRE(x25->x25 != NULL && x25->x25_len != 0); UNUSED(type); UNUSED(rdclass); + if (x25->x25_len < 4) + return (ISC_R_RANGE); + for (i = 0; i < x25->x25_len; i++) if (!isdigit(x25->x25[i] & 0xff)) return (ISC_R_RANGE); @@ -144,12 +146,9 @@ tostruct_x25(ARGS_TOSTRUCT) { dns_rdata_toregion(rdata, &r); x25->x25_len = uint8_fromregion(&r); isc_region_consume(&r, 1); - if (x25->x25_len != 0) { - x25->x25 = mem_maybedup(mctx, r.base, x25->x25_len); - if (x25->x25 == NULL) - return (ISC_R_NOMEMORY); - } else - x25->x25 = NULL; + 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); diff --git a/lib/dns/rdata/in_1/naptr_35.c b/lib/dns/rdata/in_1/naptr_35.c index f91471a994..808a2b39e3 100644 --- a/lib/dns/rdata/in_1/naptr_35.c +++ b/lib/dns/rdata/in_1/naptr_35.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: naptr_35.c,v 1.41 2001/03/16 22:53:14 bwelling Exp $ */ +/* $Id: naptr_35.c,v 1.42 2001/06/21 04:00:45 marka Exp $ */ /* Reviewed: Thu Mar 16 16:52:50 PST 2000 by bwelling */ @@ -319,12 +319,9 @@ fromstruct_in_naptr(ARGS_FROMSTRUCT) { REQUIRE(source != NULL); REQUIRE(naptr->common.rdtype == type); REQUIRE(naptr->common.rdclass == rdclass); - REQUIRE((naptr->flags == NULL && naptr->flags_len == 0) || - (naptr->flags != NULL && naptr->flags_len != 0)); - REQUIRE((naptr->service == NULL && naptr->service_len == 0) || - (naptr->service != NULL && naptr->service_len != 0)); - REQUIRE((naptr->regexp == NULL && naptr->regexp_len == 0) || - (naptr->regexp != NULL && naptr->regexp_len != 0)); + REQUIRE(naptr->flags != NULL || naptr->flags_len == 0); + REQUIRE(naptr->service != NULL && naptr->service_len == 0); + REQUIRE(naptr->regexp != NULL && naptr->regexp_len == 0); UNUSED(type); UNUSED(rdclass); @@ -371,34 +368,27 @@ tostruct_in_naptr(ARGS_TOSTRUCT) { naptr->flags_len = uint8_fromregion(&r); isc_region_consume(&r, 1); - if (naptr->flags_len != 0) { - 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); - } + 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); - if (naptr->service_len != 0) { - 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); - } + 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); - if (naptr->regexp_len != 0) { - 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); - } + 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); dns_name_fromregion(&name, &r); diff --git a/lib/dns/rdata/in_1/nsap_22.c b/lib/dns/rdata/in_1/nsap_22.c index 9b7c7238e0..244aad1838 100644 --- a/lib/dns/rdata/in_1/nsap_22.c +++ b/lib/dns/rdata/in_1/nsap_22.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nsap_22.c,v 1.31 2001/03/16 22:53:16 bwelling Exp $ */ +/* $Id: nsap_22.c,v 1.32 2001/06/21 04:00:46 marka Exp $ */ /* Reviewed: Fri Mar 17 10:41:07 PST 2000 by gson */ @@ -152,8 +152,7 @@ fromstruct_in_nsap(ARGS_FROMSTRUCT) { REQUIRE(source != NULL); REQUIRE(nsap->common.rdtype == type); REQUIRE(nsap->common.rdclass == rdclass); - REQUIRE((nsap->nsap == NULL && nsap->nsap_len == 0) || - (nsap->nsap != NULL && nsap->nsap_len != 0)); + REQUIRE(nsap->nsap != NULL || nsap->nsap_len == 0); UNUSED(type); UNUSED(rdclass); @@ -177,12 +176,9 @@ tostruct_in_nsap(ARGS_TOSTRUCT) { dns_rdata_toregion(rdata, &r); nsap->nsap_len = r.length; - if (nsap->nsap_len != 0) { - nsap->nsap = mem_maybedup(mctx, r.base, r.length); - if (nsap->nsap == NULL) - return (ISC_R_NOMEMORY); - } else - nsap->nsap = NULL; + nsap->nsap = mem_maybedup(mctx, r.base, r.length); + if (nsap->nsap == NULL) + return (ISC_R_NOMEMORY); nsap->mctx = mctx; return (ISC_R_SUCCESS); diff --git a/lib/dns/rdata/in_1/wks_11.c b/lib/dns/rdata/in_1/wks_11.c index 90ac9c07b2..8abcb4b686 100644 --- a/lib/dns/rdata/in_1/wks_11.c +++ b/lib/dns/rdata/in_1/wks_11.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: wks_11.c,v 1.42 2001/03/16 22:53:20 bwelling Exp $ */ +/* $Id: wks_11.c,v 1.43 2001/06/21 04:00:47 marka Exp $ */ /* Reviewed: Fri Mar 17 15:01:49 PST 2000 by explorer */ @@ -242,6 +242,7 @@ fromstruct_in_wks(ARGS_FROMSTRUCT) { REQUIRE(source != NULL); REQUIRE(wks->common.rdtype == type); REQUIRE(wks->common.rdclass == rdclass); + REQUIRE(wks->map != NULL || wks->map_len == 0); UNUSED(type); UNUSED(rdclass); @@ -273,12 +274,9 @@ tostruct_in_wks(ARGS_TOSTRUCT) { wks->protocol = uint16_fromregion(®ion); isc_region_consume(®ion, 2); wks->map_len = region.length; - if (wks->map_len > 0) { - wks->map = mem_maybedup(mctx, region.base, region.length); - if (wks->map == NULL) - return (ISC_R_NOMEMORY); - } else - wks->map = NULL; + wks->map = mem_maybedup(mctx, region.base, region.length); + if (wks->map == NULL) + return (ISC_R_NOMEMORY); wks->mctx = mctx; return (ISC_R_SUCCESS); }