diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b6d7ad9d43..db8f85bb1e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1415,8 +1415,10 @@ gcov: # Help gcovr process the nasty tricks in lib/dns/code.h, where we include C # source files from lib/dns/rdata/*/, using an even nastier trick. - find lib/dns/rdata/* -name "*.c" -execdir cp -f "{}" ../../ \; - # Help gcovr process inline function in the isc/hash.h - - cp -f lib/isc/include/isc/hash.h lib/dns/hash.h + # Help gcovr process inline functions in headers + - cp -f lib/isc/include/isc/*.h lib/dns/ + - cp -f lib/dns/include/dns/*.h lib/dns/ + - cp -f lib/dns/include/dns/*.h lib/ns/ # Generate XML file in the Cobertura XML format suitable for use by GitLab # for the purpose of displaying code coverage information in the diff view # of a given merge request. diff --git a/bin/tools/dnstap-read.c b/bin/tools/dnstap-read.c index fe215715e4..78b95a76fb 100644 --- a/bin/tools/dnstap-read.c +++ b/bin/tools/dnstap-read.c @@ -291,15 +291,14 @@ print_yaml(dns_dtdata_t *dt) { dns_fixedname_t fn; dns_name_t *name; isc_buffer_t b; - dns_decompress_t dctx; name = dns_fixedname_initname(&fn); isc_buffer_init(&b, m->query_zone.data, m->query_zone.len); isc_buffer_add(&b, m->query_zone.len); - dns_decompress_init(&dctx, DNS_DECOMPRESS_NONE); - result = dns_name_fromwire(name, &b, &dctx, 0, NULL); + result = dns_name_fromwire(name, &b, DNS_DECOMPRESS_NEVER, 0, + NULL); if (result == ISC_R_SUCCESS) { printf(" query_zone: "); dns_name_print(name, stdout); diff --git a/doc/dev/rdata.md b/doc/dev/rdata.md index 7c67650179..f68b0b2ffe 100644 --- a/doc/dev/rdata.md +++ b/doc/dev/rdata.md @@ -196,7 +196,7 @@ security area and must be paranoid about its input. fromwire_typename(dns_rdataclass_t class, dns_rdatatype_t type, isc_buffer_t *source, - dns_decompress_t *dctx, + dns_decompress_t dctx, bool downcase, isc_buffer_t *target); @@ -204,14 +204,14 @@ security area and must be paranoid about its input. fromwire_classname_typename(dns_rdataclass_t class, dns_rdatatype_t type, isc_buffer_t *source, - dns_decompress_t *dctx, + dns_decompress_t dctx, bool downcase, isc_buffer_t *target); `fromwire_classname_typename()` is required to set whether name compression is allowed, according to RFC 3597. - dns_decompress_setpermitted(dctx, true); /* or false */ + dctx = dns_decompress_setpermitted(dctx, true); /* or false */ |Parameter|Description | |---------|-----------------------| diff --git a/fuzz/dns_rdata_fromwire_text.c b/fuzz/dns_rdata_fromwire_text.c index 3f71538b5f..5a970e3dfa 100644 --- a/fuzz/dns_rdata_fromwire_text.c +++ b/fuzz/dns_rdata_fromwire_text.c @@ -78,7 +78,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { char totext[64 * 1044 * 4]; dns_compress_t cctx; - dns_decompress_t dctx; dns_rdatatype_t rdtype; dns_rdataclass_t rdclass; dns_rdatatype_t typelist[256] = { 1000 }; /* unknown */ @@ -135,9 +134,6 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { dns_rdatacallbacks_init(&callbacks); callbacks.warn = callbacks.error = nullmsg; - /* Disallow decompression as we are reading a packet */ - dns_decompress_init(&dctx, DNS_DECOMPRESS_NONE); - isc_buffer_constinit(&source, data, size); isc_buffer_add(&source, size); isc_buffer_setactive(&source, size); @@ -145,10 +141,11 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { isc_buffer_init(&target, fromwire, sizeof(fromwire)); /* - * Reject invalid rdata. + * Reject invalid rdata. (Disallow decompression as we are + * reading a packet) */ - CHECK(dns_rdata_fromwire(&rdata1, rdclass, rdtype, &source, &dctx, 0, - &target)); + CHECK(dns_rdata_fromwire(&rdata1, rdclass, rdtype, &source, + DNS_DECOMPRESS_NEVER, 0, &target)); assert(rdata1.length == size); /* diff --git a/lib/dns/client.c b/lib/dns/client.c index cbe70337cc..a5bbaebe97 100644 --- a/lib/dns/client.c +++ b/lib/dns/client.c @@ -1263,7 +1263,6 @@ dns_client_addtrustedkey(dns_client_t *client, dns_rdataclass_t rdclass, char rdatabuf[DST_KEY_MAXSIZE]; unsigned char digest[ISC_MAX_MD_SIZE]; dns_rdata_ds_t ds; - dns_decompress_t dctx; dns_rdata_t rdata; isc_buffer_t b; @@ -1285,12 +1284,10 @@ dns_client_addtrustedkey(dns_client_t *client, dns_rdataclass_t rdclass, } isc_buffer_init(&b, rdatabuf, sizeof(rdatabuf)); - dns_decompress_init(&dctx, DNS_DECOMPRESS_NONE); dns_rdata_init(&rdata); isc_buffer_setactive(databuf, isc_buffer_usedlength(databuf)); - CHECK(dns_rdata_fromwire(&rdata, rdclass, rdtype, databuf, &dctx, 0, - &b)); - dns_decompress_invalidate(&dctx); + CHECK(dns_rdata_fromwire(&rdata, rdclass, rdtype, databuf, + DNS_DECOMPRESS_NEVER, 0, &b)); if (rdtype == dns_rdatatype_ds) { CHECK(dns_rdata_tostruct(&rdata, &ds, NULL)); diff --git a/lib/dns/compress.c b/lib/dns/compress.c index 8e49f9bbce..f195e98b06 100644 --- a/lib/dns/compress.c +++ b/lib/dns/compress.c @@ -30,9 +30,6 @@ #define CCTX_MAGIC ISC_MAGIC('C', 'C', 'T', 'X') #define VALID_CCTX(x) ISC_MAGIC_VALID(x, CCTX_MAGIC) -#define DCTX_MAGIC ISC_MAGIC('D', 'C', 'T', 'X') -#define VALID_DCTX(x) ISC_MAGIC_VALID(x, DCTX_MAGIC) - static unsigned char maptolower[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, @@ -506,47 +503,3 @@ dns_compress_rollback(dns_compress_t *cctx, uint16_t offset) { } } } - -/*** - *** Decompression - ***/ - -void -dns_decompress_init(dns_decompress_t *dctx, dns_decompresstype_t type) { - REQUIRE(dctx != NULL); - - *dctx = (dns_decompress_t){ - .magic = DCTX_MAGIC, - .type = type, - }; -} - -void -dns_decompress_invalidate(dns_decompress_t *dctx) { - REQUIRE(VALID_DCTX(dctx)); - dctx->magic = 0; -} - -void -dns_decompress_setpermitted(dns_decompress_t *dctx, bool permitted) { - REQUIRE(VALID_DCTX(dctx)); - - switch (dctx->type) { - case DNS_DECOMPRESS_ANY: - dctx->permitted = true; - break; - case DNS_DECOMPRESS_NONE: - dctx->permitted = false; - break; - case DNS_DECOMPRESS_STRICT: - dctx->permitted = permitted; - break; - } -} - -bool -dns_decompress_getpermitted(dns_decompress_t *dctx) { - REQUIRE(VALID_DCTX(dctx)); - - return (dctx->permitted); -} diff --git a/lib/dns/include/dns/compress.h b/lib/dns/include/dns/compress.h index f3c6a7e12d..151a860fbe 100644 --- a/lib/dns/include/dns/compress.h +++ b/lib/dns/include/dns/compress.h @@ -72,16 +72,11 @@ struct dns_compress { isc_mem_t *mctx; /*%< Memory context. */ }; -typedef enum { - DNS_DECOMPRESS_ANY, /*%< Any compression */ - DNS_DECOMPRESS_STRICT, /*%< Allowed compression */ - DNS_DECOMPRESS_NONE /*%< No compression */ -} dns_decompresstype_t; - -struct dns_decompress { - unsigned int magic; /*%< Magic number. */ - dns_decompresstype_t type; /*%< Strict checking */ - bool permitted; +enum dns_decompress { + DNS_DECOMPRESS_DEFAULT, + DNS_DECOMPRESS_PERMITTED, + DNS_DECOMPRESS_NEVER, + DNS_DECOMPRESS_ALWAYS, }; isc_result_t @@ -204,7 +199,6 @@ dns_compress_add(dns_compress_t *cctx, const dns_name_t *name, void dns_compress_rollback(dns_compress_t *cctx, uint16_t offset); - /*%< * Remove any compression pointers from global table >= offset. * @@ -212,45 +206,27 @@ dns_compress_rollback(dns_compress_t *cctx, uint16_t offset); *\li 'cctx' is initialized. */ -void -dns_decompress_init(dns_decompress_t *dctx, dns_decompresstype_t type); - -/*%< - * Initializes 'dctx'. - * Records 'edns' and 'type' into the structure. - * - * Requires: - *\li 'dctx' to be a valid pointer. +/*% + * Set whether decompression is allowed, according to RFC 3597 */ +static inline dns_decompress_t /* inline to suppress code generation */ +dns_decompress_setpermitted(dns_decompress_t dctx, bool permitted) { + if (dctx == DNS_DECOMPRESS_NEVER || dctx == DNS_DECOMPRESS_ALWAYS) { + return (dctx); + } else if (permitted) { + return (DNS_DECOMPRESS_PERMITTED); + } else { + return (DNS_DECOMPRESS_DEFAULT); + } +} -void -dns_decompress_invalidate(dns_decompress_t *dctx); - -/*%< - * Invalidates 'dctx'. - * - * Requires: - *\li 'dctx' to be initialized - */ - -void -dns_decompress_setpermitted(dns_decompress_t *dctx, bool permitted); - -/*%< - * Sets whether decompression is allowed, according to RFC 3597 - * - * Requires: - *\li 'dctx' to be initialized - */ - -bool -dns_decompress_getpermitted(dns_decompress_t *dctx); - -/*%< +/*% * Returns whether decompression is allowed here - * - * Requires: - *\li 'dctx' to be initialized */ +static inline bool /* inline to suppress code generation */ +dns_decompress_getpermitted(dns_decompress_t dctx) { + return (dctx == DNS_DECOMPRESS_ALWAYS || + dctx == DNS_DECOMPRESS_PERMITTED); +} ISC_LANG_ENDDECLS diff --git a/lib/dns/include/dns/name.h b/lib/dns/include/dns/name.h index 8063799490..e294b9068b 100644 --- a/lib/dns/include/dns/name.h +++ b/lib/dns/include/dns/name.h @@ -691,9 +691,8 @@ dns_name_toregion(const dns_name_t *name, isc_region_t *r); */ isc_result_t -dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, - dns_decompress_t *dctx, unsigned int options, - isc_buffer_t *target); +dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, dns_decompress_t dctx, + unsigned int options, isc_buffer_t *target); /*%< * Copy the possibly-compressed name at source (active region) into target, * decompressing it. diff --git a/lib/dns/include/dns/rdata.h b/lib/dns/include/dns/rdata.h index 03298c7c71..029685a6ef 100644 --- a/lib/dns/include/dns/rdata.h +++ b/lib/dns/include/dns/rdata.h @@ -281,7 +281,7 @@ dns_rdata_toregion(const dns_rdata_t *rdata, isc_region_t *r); isc_result_t dns_rdata_fromwire(dns_rdata_t *rdata, dns_rdataclass_t rdclass, dns_rdatatype_t type, isc_buffer_t *source, - dns_decompress_t *dctx, unsigned int options, + dns_decompress_t dctx, unsigned int options, isc_buffer_t *target); /*%< * Copy the possibly-compressed rdata at source into the target region. diff --git a/lib/dns/include/dns/types.h b/lib/dns/include/dns/types.h index eece8448d3..4d69639f13 100644 --- a/lib/dns/include/dns/types.h +++ b/lib/dns/include/dns/types.h @@ -65,7 +65,7 @@ typedef struct dns_dlzdb dns_dlzdb_t; typedef ISC_LIST(dns_dlzdb_t) dns_dlzdblist_t; typedef struct dns_dyndbctx dns_dyndbctx_t; typedef struct dns_sdlzimplementation dns_sdlzimplementation_t; -typedef struct dns_decompress dns_decompress_t; +typedef enum dns_decompress dns_decompress_t; typedef struct dns_dispatch dns_dispatch_t; typedef struct dns_dispatchlist dns_dispatchlist_t; typedef struct dns_dispatchset dns_dispatchset_t; diff --git a/lib/dns/journal.c b/lib/dns/journal.c index 9732682d03..664ef23269 100644 --- a/lib/dns/journal.c +++ b/lib/dns/journal.c @@ -738,7 +738,7 @@ journal_open(isc_mem_t *mctx, const char *filename, bool writable, bool create, */ isc_buffer_init(&j->it.source, NULL, 0); isc_buffer_init(&j->it.target, NULL, 0); - dns_decompress_init(&j->it.dctx, DNS_DECOMPRESS_NONE); + j->it.dctx = DNS_DECOMPRESS_NEVER; j->state = writable ? JOURNAL_STATE_WRITE : JOURNAL_STATE_READ; @@ -1438,7 +1438,6 @@ dns_journal_destroy(dns_journal_t **journalp) { j->it.result = ISC_R_FAILURE; dns_name_invalidate(&j->it.name); - dns_decompress_invalidate(&j->it.dctx); if (j->rawindex != NULL) { isc_mem_put(j->mctx, j->rawindex, j->header.index_size * sizeof(journal_rawpos_t)); @@ -2029,7 +2028,7 @@ read_one_rr(dns_journal_t *j) { */ isc_buffer_setactive(&j->it.source, j->it.source.used - j->it.source.current); - CHECK(dns_name_fromwire(&j->it.name, &j->it.source, &j->it.dctx, 0, + CHECK(dns_name_fromwire(&j->it.name, &j->it.source, j->it.dctx, 0, &j->it.target)); /* @@ -2061,7 +2060,7 @@ read_one_rr(dns_journal_t *j) { isc_buffer_setactive(&j->it.source, rdlen); dns_rdata_reset(&j->it.rdata); CHECK(dns_rdata_fromwire(&j->it.rdata, rdclass, rdtype, &j->it.source, - &j->it.dctx, 0, &j->it.target)); + j->it.dctx, 0, &j->it.target)); j->it.ttl = ttl; j->it.xpos += sizeof(journal_rawrrhdr_t) + rrhdr.size; diff --git a/lib/dns/master.c b/lib/dns/master.c index ccedc1af84..598bde02de 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -2342,7 +2342,7 @@ load_raw(dns_loadctx_t *lctx) { dns_decompress_t dctx; callbacks = lctx->callbacks; - dns_decompress_init(&dctx, DNS_DECOMPRESS_NONE); + dctx = DNS_DECOMPRESS_NEVER; if (lctx->first) { result = load_header(lctx); @@ -2475,7 +2475,7 @@ load_raw(dns_loadctx_t *lctx) { } isc_buffer_setactive(&target, (unsigned int)namelen); - result = dns_name_fromwire(name, &target, &dctx, 0, NULL); + result = dns_name_fromwire(name, &target, dctx, 0, NULL); if (result != ISC_R_SUCCESS) { goto cleanup; } @@ -2564,7 +2564,7 @@ load_raw(dns_loadctx_t *lctx) { (unsigned int)rdlen); result = dns_rdata_fromwire( &rdata[i], rdatalist.rdclass, rdatalist.type, - &target, &dctx, 0, &buf); + &target, dctx, 0, &buf); if (result != ISC_R_SUCCESS) { goto cleanup; } diff --git a/lib/dns/message.c b/lib/dns/message.c index e567202eb9..da101eeadc 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -862,7 +862,7 @@ dns_message_findtype(const dns_name_t *name, dns_rdatatype_t type, */ static isc_result_t getname(dns_name_t *name, isc_buffer_t *source, dns_message_t *msg, - dns_decompress_t *dctx) { + dns_decompress_t dctx) { isc_buffer_t *scratch; isc_result_t result; unsigned int tries; @@ -896,7 +896,7 @@ getname(dns_name_t *name, isc_buffer_t *source, dns_message_t *msg, } static isc_result_t -getrdata(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx, +getrdata(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t dctx, dns_rdataclass_t rdclass, dns_rdatatype_t rdtype, unsigned int rdatalen, dns_rdata_t *rdata) { isc_buffer_t *scratch; @@ -960,7 +960,7 @@ getrdata(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx, } while (0) static isc_result_t -getquestions(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx, +getquestions(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t dctx, unsigned int options) { isc_region_t r; unsigned int count; @@ -1175,7 +1175,7 @@ auth_signed(dns_namelist_t *section) { } static isc_result_t -getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx, +getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t dctx, dns_section_t sectionid, unsigned int options) { isc_region_t r; unsigned int count, rdatalen; @@ -1681,10 +1681,9 @@ dns_message_parse(dns_message_t *msg, isc_buffer_t *source, msg->header_ok = 1; msg->state = DNS_SECTION_QUESTION; - dns_decompress_init(&dctx, DNS_DECOMPRESS_ANY); - dns_decompress_setpermitted(&dctx, true); + dctx = DNS_DECOMPRESS_ALWAYS; - ret = getquestions(source, msg, &dctx, options); + ret = getquestions(source, msg, dctx, options); if (ret == ISC_R_UNEXPECTEDEND && ignore_tc) { goto truncated; } @@ -1697,7 +1696,7 @@ dns_message_parse(dns_message_t *msg, isc_buffer_t *source, } msg->question_ok = 1; - ret = getsection(source, msg, &dctx, DNS_SECTION_ANSWER, options); + ret = getsection(source, msg, dctx, DNS_SECTION_ANSWER, options); if (ret == ISC_R_UNEXPECTEDEND && ignore_tc) { goto truncated; } @@ -1709,7 +1708,7 @@ dns_message_parse(dns_message_t *msg, isc_buffer_t *source, return (ret); } - ret = getsection(source, msg, &dctx, DNS_SECTION_AUTHORITY, options); + ret = getsection(source, msg, dctx, DNS_SECTION_AUTHORITY, options); if (ret == ISC_R_UNEXPECTEDEND && ignore_tc) { goto truncated; } @@ -1721,7 +1720,7 @@ dns_message_parse(dns_message_t *msg, isc_buffer_t *source, return (ret); } - ret = getsection(source, msg, &dctx, DNS_SECTION_ADDITIONAL, options); + ret = getsection(source, msg, dctx, DNS_SECTION_ADDITIONAL, options); if (ret == ISC_R_UNEXPECTEDEND && ignore_tc) { goto truncated; } diff --git a/lib/dns/name.c b/lib/dns/name.c index 76dd6b4470..26114fde30 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -1737,9 +1737,8 @@ set_offsets(const dns_name_t *name, unsigned char *offsets, } isc_result_t -dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, - dns_decompress_t *dctx, unsigned int options, - isc_buffer_t *target) { +dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, dns_decompress_t dctx, + unsigned int options, isc_buffer_t *target) { unsigned char *cdata, *ndata; unsigned int cused; /* Bytes of compressed name data used */ unsigned int nused, labels, n, nmax; @@ -1769,7 +1768,6 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, isc_buffer_clear(target); } - REQUIRE(dctx != NULL); REQUIRE(BINDABLE(name)); INIT_OFFSETS(name, offsets, odata); @@ -1843,7 +1841,7 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, /* * 14-bit compression pointer */ - if (!dctx->permitted) { + if (!dns_decompress_getpermitted(dctx)) { return (DNS_R_DISALLOWED); } new_current = c & 0x3F; diff --git a/lib/dns/nsec3.c b/lib/dns/nsec3.c index 5644f1e9e7..fca6459343 100644 --- a/lib/dns/nsec3.c +++ b/lib/dns/nsec3.c @@ -971,7 +971,6 @@ failure: bool dns_nsec3param_fromprivate(dns_rdata_t *src, dns_rdata_t *target, unsigned char *buf, size_t buflen) { - dns_decompress_t dctx; isc_result_t result; isc_buffer_t buf1; isc_buffer_t buf2; @@ -988,11 +987,9 @@ dns_nsec3param_fromprivate(dns_rdata_t *src, dns_rdata_t *target, isc_buffer_add(&buf1, src->length - 1); isc_buffer_setactive(&buf1, src->length - 1); isc_buffer_init(&buf2, buf, (unsigned int)buflen); - dns_decompress_init(&dctx, DNS_DECOMPRESS_NONE); result = dns_rdata_fromwire(target, src->rdclass, - dns_rdatatype_nsec3param, &buf1, &dctx, 0, - &buf2); - dns_decompress_invalidate(&dctx); + dns_rdatatype_nsec3param, &buf1, + DNS_DECOMPRESS_NEVER, 0, &buf2); return (result == ISC_R_SUCCESS); } diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index 44e3030723..23c863edbb 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -97,7 +97,7 @@ #define ARGS_FROMWIRE \ int rdclass, dns_rdatatype_t type, isc_buffer_t *source, \ - dns_decompress_t *dctx, unsigned int options, \ + dns_decompress_t dctx, unsigned int options, \ isc_buffer_t *target #define CALL_FROMWIRE rdclass, type, source, dctx, options, target @@ -611,11 +611,9 @@ check_private(isc_buffer_t *source, dns_secalg_t alg) { isc_region_t sr; if (alg == DNS_KEYALG_PRIVATEDNS) { dns_fixedname_t fixed; - dns_decompress_t dctx; - dns_decompress_init(&dctx, DNS_DECOMPRESS_STRICT); RETERR(dns_name_fromwire(dns_fixedname_initname(&fixed), source, - &dctx, 0, NULL)); + DNS_DECOMPRESS_DEFAULT, 0, NULL)); /* * There should be a public key or signature after the key name. */ @@ -806,7 +804,7 @@ dns_rdata_toregion(const dns_rdata_t *rdata, isc_region_t *r) { isc_result_t dns_rdata_fromwire(dns_rdata_t *rdata, dns_rdataclass_t rdclass, dns_rdatatype_t type, isc_buffer_t *source, - dns_decompress_t *dctx, unsigned int options, + dns_decompress_t dctx, unsigned int options, isc_buffer_t *target) { isc_result_t result = ISC_R_NOTIMPLEMENTED; isc_region_t region; @@ -816,7 +814,6 @@ dns_rdata_fromwire(dns_rdata_t *rdata, dns_rdataclass_t rdclass, uint32_t activelength; unsigned int length; - REQUIRE(dctx != NULL); if (rdata != NULL) { REQUIRE(DNS_RDATA_INITIALIZED(rdata)); REQUIRE(DNS_RDATA_VALIDFLAGS(rdata)); @@ -924,13 +921,11 @@ dns_rdata_towire(dns_rdata_t *rdata, dns_compress_t *cctx, static isc_result_t rdata_validate(isc_buffer_t *src, isc_buffer_t *dest, dns_rdataclass_t rdclass, dns_rdatatype_t type) { - dns_decompress_t dctx; isc_result_t result; - dns_decompress_init(&dctx, DNS_DECOMPRESS_NONE); isc_buffer_setactive(src, isc_buffer_usedlength(src)); - result = dns_rdata_fromwire(NULL, rdclass, type, src, &dctx, 0, dest); - dns_decompress_invalidate(&dctx); + result = dns_rdata_fromwire(NULL, rdclass, type, src, + DNS_DECOMPRESS_NEVER, 0, dest); return (result); } diff --git a/lib/dns/rdata/any_255/tsig_250.c b/lib/dns/rdata/any_255/tsig_250.c index f6829c67c2..3dbd73349b 100644 --- a/lib/dns/rdata/any_255/tsig_250.c +++ b/lib/dns/rdata/any_255/tsig_250.c @@ -263,7 +263,7 @@ fromwire_any_tsig(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); /* * Algorithm Name. diff --git a/lib/dns/rdata/ch_3/a_1.c b/lib/dns/rdata/ch_3/a_1.c index b5514c1659..09051af0cc 100644 --- a/lib/dns/rdata/ch_3/a_1.c +++ b/lib/dns/rdata/ch_3/a_1.c @@ -105,7 +105,7 @@ fromwire_ch_a(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, true); + dctx = dns_decompress_setpermitted(dctx, true); dns_name_init(&name, NULL); diff --git a/lib/dns/rdata/generic/afsdb_18.c b/lib/dns/rdata/generic/afsdb_18.c index 63b3149cd6..3b24048479 100644 --- a/lib/dns/rdata/generic/afsdb_18.c +++ b/lib/dns/rdata/generic/afsdb_18.c @@ -101,7 +101,7 @@ fromwire_afsdb(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); dns_name_init(&name, NULL); diff --git a/lib/dns/rdata/generic/amtrelay_260.c b/lib/dns/rdata/generic/amtrelay_260.c index 13b707cf82..616c6ff2a6 100644 --- a/lib/dns/rdata/generic/amtrelay_260.c +++ b/lib/dns/rdata/generic/amtrelay_260.c @@ -192,7 +192,7 @@ fromwire_amtrelay(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); isc_buffer_activeregion(source, ®ion); if (region.length < 2) { diff --git a/lib/dns/rdata/generic/cname_5.c b/lib/dns/rdata/generic/cname_5.c index 61b2e9f278..3cc6918c52 100644 --- a/lib/dns/rdata/generic/cname_5.c +++ b/lib/dns/rdata/generic/cname_5.c @@ -71,7 +71,7 @@ fromwire_cname(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, true); + dctx = dns_decompress_setpermitted(dctx, true); dns_name_init(&name, NULL); return (dns_name_fromwire(&name, source, dctx, options, target)); diff --git a/lib/dns/rdata/generic/dname_39.c b/lib/dns/rdata/generic/dname_39.c index cd7a0d8f75..b061ccb13a 100644 --- a/lib/dns/rdata/generic/dname_39.c +++ b/lib/dns/rdata/generic/dname_39.c @@ -72,7 +72,7 @@ fromwire_dname(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); dns_name_init(&name, NULL); return (dns_name_fromwire(&name, source, dctx, options, target)); diff --git a/lib/dns/rdata/generic/hip_55.c b/lib/dns/rdata/generic/hip_55.c index 34d7940faa..041f561d3e 100644 --- a/lib/dns/rdata/generic/hip_55.c +++ b/lib/dns/rdata/generic/hip_55.c @@ -226,7 +226,7 @@ fromwire_hip(ARGS_FROMWIRE) { RETERR(mem_tobuffer(target, rr.base, 4 + len)); isc_buffer_forward(source, 4 + len); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); while (isc_buffer_activelength(source) > 0) { dns_name_init(&name, NULL); RETERR(dns_name_fromwire(&name, source, dctx, options, target)); diff --git a/lib/dns/rdata/generic/ipseckey_45.c b/lib/dns/rdata/generic/ipseckey_45.c index 5122ebe1d2..c69280d79f 100644 --- a/lib/dns/rdata/generic/ipseckey_45.c +++ b/lib/dns/rdata/generic/ipseckey_45.c @@ -221,7 +221,7 @@ fromwire_ipseckey(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); dns_name_init(&name, NULL); diff --git a/lib/dns/rdata/generic/lp_107.c b/lib/dns/rdata/generic/lp_107.c index 91658938ce..d02e4aa00d 100644 --- a/lib/dns/rdata/generic/lp_107.c +++ b/lib/dns/rdata/generic/lp_107.c @@ -88,7 +88,7 @@ fromwire_lp(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, true); + dctx = dns_decompress_setpermitted(dctx, true); dns_name_init(&name, NULL); diff --git a/lib/dns/rdata/generic/mb_7.c b/lib/dns/rdata/generic/mb_7.c index 4d417ded87..64e3ed3236 100644 --- a/lib/dns/rdata/generic/mb_7.c +++ b/lib/dns/rdata/generic/mb_7.c @@ -70,7 +70,7 @@ fromwire_mb(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, true); + dctx = dns_decompress_setpermitted(dctx, true); dns_name_init(&name, NULL); return (dns_name_fromwire(&name, source, dctx, options, target)); diff --git a/lib/dns/rdata/generic/md_3.c b/lib/dns/rdata/generic/md_3.c index 7711eac084..e817ac0338 100644 --- a/lib/dns/rdata/generic/md_3.c +++ b/lib/dns/rdata/generic/md_3.c @@ -70,7 +70,7 @@ fromwire_md(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, true); + dctx = dns_decompress_setpermitted(dctx, true); dns_name_init(&name, NULL); return (dns_name_fromwire(&name, source, dctx, options, target)); diff --git a/lib/dns/rdata/generic/mf_4.c b/lib/dns/rdata/generic/mf_4.c index 5130e5006a..e28878f334 100644 --- a/lib/dns/rdata/generic/mf_4.c +++ b/lib/dns/rdata/generic/mf_4.c @@ -70,7 +70,7 @@ fromwire_mf(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, true); + dctx = dns_decompress_setpermitted(dctx, true); dns_name_init(&name, NULL); return (dns_name_fromwire(&name, source, dctx, options, target)); diff --git a/lib/dns/rdata/generic/mg_8.c b/lib/dns/rdata/generic/mg_8.c index 7285c5cb36..60c85c3ba8 100644 --- a/lib/dns/rdata/generic/mg_8.c +++ b/lib/dns/rdata/generic/mg_8.c @@ -70,7 +70,7 @@ fromwire_mg(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, true); + dctx = dns_decompress_setpermitted(dctx, true); dns_name_init(&name, NULL); return (dns_name_fromwire(&name, source, dctx, options, target)); diff --git a/lib/dns/rdata/generic/minfo_14.c b/lib/dns/rdata/generic/minfo_14.c index 03200ba9d9..3ccf77a099 100644 --- a/lib/dns/rdata/generic/minfo_14.c +++ b/lib/dns/rdata/generic/minfo_14.c @@ -98,7 +98,7 @@ fromwire_minfo(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, true); + dctx = dns_decompress_setpermitted(dctx, true); dns_name_init(&rmail, NULL); dns_name_init(&email, NULL); diff --git a/lib/dns/rdata/generic/mr_9.c b/lib/dns/rdata/generic/mr_9.c index 60f59cacf6..5fc77963d4 100644 --- a/lib/dns/rdata/generic/mr_9.c +++ b/lib/dns/rdata/generic/mr_9.c @@ -70,7 +70,7 @@ fromwire_mr(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, true); + dctx = dns_decompress_setpermitted(dctx, true); dns_name_init(&name, NULL); return (dns_name_fromwire(&name, source, dctx, options, target)); diff --git a/lib/dns/rdata/generic/mx_15.c b/lib/dns/rdata/generic/mx_15.c index 4614c95ac5..a914540ccc 100644 --- a/lib/dns/rdata/generic/mx_15.c +++ b/lib/dns/rdata/generic/mx_15.c @@ -134,7 +134,7 @@ fromwire_mx(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, true); + dctx = dns_decompress_setpermitted(dctx, true); dns_name_init(&name, NULL); diff --git a/lib/dns/rdata/generic/naptr_35.c b/lib/dns/rdata/generic/naptr_35.c index afa1a5d4b8..5babd31b93 100644 --- a/lib/dns/rdata/generic/naptr_35.c +++ b/lib/dns/rdata/generic/naptr_35.c @@ -311,7 +311,7 @@ fromwire_naptr(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); dns_name_init(&name, NULL); diff --git a/lib/dns/rdata/generic/ns_2.c b/lib/dns/rdata/generic/ns_2.c index ce9f44a112..32b5430656 100644 --- a/lib/dns/rdata/generic/ns_2.c +++ b/lib/dns/rdata/generic/ns_2.c @@ -81,7 +81,7 @@ fromwire_ns(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, true); + dctx = dns_decompress_setpermitted(dctx, true); dns_name_init(&name, NULL); return (dns_name_fromwire(&name, source, dctx, options, target)); diff --git a/lib/dns/rdata/generic/nsec_47.c b/lib/dns/rdata/generic/nsec_47.c index 571a0ce37b..e36ff65552 100644 --- a/lib/dns/rdata/generic/nsec_47.c +++ b/lib/dns/rdata/generic/nsec_47.c @@ -85,7 +85,7 @@ fromwire_nsec(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); dns_name_init(&name, NULL); RETERR(dns_name_fromwire(&name, source, dctx, options, target)); diff --git a/lib/dns/rdata/generic/nxt_30.c b/lib/dns/rdata/generic/nxt_30.c index 5dce8a03fc..7d62c56a74 100644 --- a/lib/dns/rdata/generic/nxt_30.c +++ b/lib/dns/rdata/generic/nxt_30.c @@ -144,7 +144,7 @@ fromwire_nxt(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); dns_name_init(&name, NULL); RETERR(dns_name_fromwire(&name, source, dctx, options, target)); diff --git a/lib/dns/rdata/generic/proforma.c b/lib/dns/rdata/generic/proforma.c index 2c286227b0..fa7982fb7a 100644 --- a/lib/dns/rdata/generic/proforma.c +++ b/lib/dns/rdata/generic/proforma.c @@ -41,7 +41,7 @@ static isc_result_t fromwire_ #(ARGS_FROMWIRE) { REQUIRE(rdclass == #); /* see RFC 3597 */ - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); return (ISC_R_NOTIMPLEMENTED); } diff --git a/lib/dns/rdata/generic/ptr_12.c b/lib/dns/rdata/generic/ptr_12.c index f584b7a80e..8acffe797e 100644 --- a/lib/dns/rdata/generic/ptr_12.c +++ b/lib/dns/rdata/generic/ptr_12.c @@ -83,7 +83,7 @@ fromwire_ptr(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, true); + dctx = dns_decompress_setpermitted(dctx, true); dns_name_init(&name, NULL); return (dns_name_fromwire(&name, source, dctx, options, target)); diff --git a/lib/dns/rdata/generic/rp_17.c b/lib/dns/rdata/generic/rp_17.c index 6e1800d7cd..dfba5feca9 100644 --- a/lib/dns/rdata/generic/rp_17.c +++ b/lib/dns/rdata/generic/rp_17.c @@ -99,7 +99,7 @@ fromwire_rp(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); dns_name_init(&rmail, NULL); dns_name_init(&email, NULL); diff --git a/lib/dns/rdata/generic/rrsig_46.c b/lib/dns/rdata/generic/rrsig_46.c index d457160b04..0aba846913 100644 --- a/lib/dns/rdata/generic/rrsig_46.c +++ b/lib/dns/rdata/generic/rrsig_46.c @@ -303,7 +303,7 @@ fromwire_rrsig(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); isc_buffer_activeregion(source, &sr); /* diff --git a/lib/dns/rdata/generic/rt_21.c b/lib/dns/rdata/generic/rt_21.c index f36836f3ab..a22ff600d7 100644 --- a/lib/dns/rdata/generic/rt_21.c +++ b/lib/dns/rdata/generic/rt_21.c @@ -97,7 +97,7 @@ fromwire_rt(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); dns_name_init(&name, NULL); diff --git a/lib/dns/rdata/generic/sig_24.c b/lib/dns/rdata/generic/sig_24.c index f6a10f7a44..1d4b6f7bc0 100644 --- a/lib/dns/rdata/generic/sig_24.c +++ b/lib/dns/rdata/generic/sig_24.c @@ -266,7 +266,7 @@ fromwire_sig(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); isc_buffer_activeregion(source, &sr); /* diff --git a/lib/dns/rdata/generic/soa_6.c b/lib/dns/rdata/generic/soa_6.c index 2cba492c77..e72ff5cc40 100644 --- a/lib/dns/rdata/generic/soa_6.c +++ b/lib/dns/rdata/generic/soa_6.c @@ -165,7 +165,7 @@ fromwire_soa(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, true); + dctx = dns_decompress_setpermitted(dctx, true); dns_name_init(&mname, NULL); dns_name_init(&rname, NULL); diff --git a/lib/dns/rdata/generic/talink_58.c b/lib/dns/rdata/generic/talink_58.c index b47220f0b9..710efb5a98 100644 --- a/lib/dns/rdata/generic/talink_58.c +++ b/lib/dns/rdata/generic/talink_58.c @@ -88,7 +88,7 @@ fromwire_talink(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); dns_name_init(&prev, NULL); dns_name_init(&next, NULL); diff --git a/lib/dns/rdata/generic/tkey_249.c b/lib/dns/rdata/generic/tkey_249.c index 34189cf082..a77054da11 100644 --- a/lib/dns/rdata/generic/tkey_249.c +++ b/lib/dns/rdata/generic/tkey_249.c @@ -253,7 +253,7 @@ fromwire_tkey(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); /* * Algorithm. diff --git a/lib/dns/rdata/in_1/a6_38.c b/lib/dns/rdata/in_1/a6_38.c index ea2f13fe9b..83716952aa 100644 --- a/lib/dns/rdata/in_1/a6_38.c +++ b/lib/dns/rdata/in_1/a6_38.c @@ -158,7 +158,7 @@ fromwire_in_a6(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); isc_buffer_activeregion(source, &sr); /* diff --git a/lib/dns/rdata/in_1/apl_42.c b/lib/dns/rdata/in_1/apl_42.c index c2862d3f1c..d7f12f962f 100644 --- a/lib/dns/rdata/in_1/apl_42.c +++ b/lib/dns/rdata/in_1/apl_42.c @@ -276,7 +276,8 @@ fromstruct_in_apl(ARGS_FROMSTRUCT) { isc_buffer_init(&b, apl->apl, apl->apl_len); isc_buffer_add(&b, apl->apl_len); isc_buffer_setactive(&b, apl->apl_len); - return (fromwire_in_apl(rdclass, type, &b, NULL, false, target)); + return (fromwire_in_apl(rdclass, type, &b, DNS_DECOMPRESS_DEFAULT, + false, target)); } static isc_result_t diff --git a/lib/dns/rdata/in_1/kx_36.c b/lib/dns/rdata/in_1/kx_36.c index 355734332d..9a271b9c70 100644 --- a/lib/dns/rdata/in_1/kx_36.c +++ b/lib/dns/rdata/in_1/kx_36.c @@ -89,7 +89,7 @@ fromwire_in_kx(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); dns_name_init(&name, NULL); diff --git a/lib/dns/rdata/in_1/nsap-ptr_23.c b/lib/dns/rdata/in_1/nsap-ptr_23.c index 3345aa82c9..a3cb908ca7 100644 --- a/lib/dns/rdata/in_1/nsap-ptr_23.c +++ b/lib/dns/rdata/in_1/nsap-ptr_23.c @@ -75,7 +75,7 @@ fromwire_in_nsap_ptr(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); dns_name_init(&name, NULL); return (dns_name_fromwire(&name, source, dctx, options, target)); diff --git a/lib/dns/rdata/in_1/px_26.c b/lib/dns/rdata/in_1/px_26.c index 1223664153..8f5af8783a 100644 --- a/lib/dns/rdata/in_1/px_26.c +++ b/lib/dns/rdata/in_1/px_26.c @@ -119,7 +119,7 @@ fromwire_in_px(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); dns_name_init(&name, NULL); diff --git a/lib/dns/rdata/in_1/srv_33.c b/lib/dns/rdata/in_1/srv_33.c index df10c819d8..da07c95986 100644 --- a/lib/dns/rdata/in_1/srv_33.c +++ b/lib/dns/rdata/in_1/srv_33.c @@ -149,7 +149,7 @@ fromwire_in_srv(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); dns_name_init(&name, NULL); diff --git a/lib/dns/rdata/in_1/svcb_64.c b/lib/dns/rdata/in_1/svcb_64.c index 00fdf24b25..ed9d2d6537 100644 --- a/lib/dns/rdata/in_1/svcb_64.c +++ b/lib/dns/rdata/in_1/svcb_64.c @@ -756,7 +756,7 @@ generic_fromwire_in_svcb(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); - dns_decompress_setpermitted(dctx, false); + dctx = dns_decompress_setpermitted(dctx, false); dns_name_init(&name, NULL); diff --git a/tests/dns/name_test.c b/tests/dns/name_test.c index 4bb4655914..2eeaa4bf69 100644 --- a/tests/dns/name_test.c +++ b/tests/dns/name_test.c @@ -124,7 +124,7 @@ ISC_RUN_TEST_IMPL(fullcompare) { static void compress_test(dns_name_t *name1, dns_name_t *name2, dns_name_t *name3, unsigned char *expected, unsigned int length, - dns_compress_t *cctx, dns_decompress_t *dctx) { + dns_compress_t *cctx, dns_decompress_t dctx) { isc_buffer_t source; isc_buffer_t target; dns_name_t name; @@ -151,7 +151,6 @@ compress_test(dns_name_t *name1, dns_name_t *name2, dns_name_t *name3, ISC_R_SUCCESS); RUNTIME_CHECK(dns_name_fromwire(&name, &source, dctx, 0, &target) == ISC_R_SUCCESS); - dns_decompress_invalidate(dctx); assert_int_equal(target.used, length); assert_true(memcmp(target.base, expected, target.used) == 0); @@ -193,11 +192,10 @@ ISC_RUN_TEST_IMPL(compression) { permitted = false; assert_int_equal(dns_compress_init(&cctx, mctx), ISC_R_SUCCESS); dns_compress_setpermitted(&cctx, permitted); - dns_decompress_init(&dctx, DNS_DECOMPRESS_STRICT); - dns_decompress_setpermitted(&dctx, permitted); + dctx = dns_decompress_setpermitted(DNS_DECOMPRESS_DEFAULT, permitted); compress_test(&name1, &name2, &name3, plain, sizeof(plain), &cctx, - &dctx); + dctx); dns_compress_rollback(&cctx, 0); dns_compress_invalidate(&cctx); @@ -206,11 +204,10 @@ ISC_RUN_TEST_IMPL(compression) { permitted = true; assert_int_equal(dns_compress_init(&cctx, mctx), ISC_R_SUCCESS); dns_compress_setpermitted(&cctx, permitted); - dns_decompress_init(&dctx, DNS_DECOMPRESS_STRICT); - dns_decompress_setpermitted(&dctx, permitted); + dctx = dns_decompress_setpermitted(DNS_DECOMPRESS_DEFAULT, permitted); compress_test(&name1, &name2, &name3, plain, sizeof(plain), &cctx, - &dctx); + dctx); dns_compress_rollback(&cctx, 0); dns_compress_invalidate(&cctx); @@ -220,11 +217,10 @@ ISC_RUN_TEST_IMPL(compression) { assert_int_equal(dns_compress_init(&cctx, mctx), ISC_R_SUCCESS); dns_compress_setpermitted(&cctx, permitted); dns_compress_disable(&cctx); - dns_decompress_init(&dctx, DNS_DECOMPRESS_STRICT); - dns_decompress_setpermitted(&dctx, permitted); + dctx = dns_decompress_setpermitted(DNS_DECOMPRESS_DEFAULT, permitted); compress_test(&name1, &name2, &name3, plain, sizeof(plain), &cctx, - &dctx); + dctx); dns_compress_rollback(&cctx, 0); dns_compress_invalidate(&cctx); @@ -234,11 +230,10 @@ ISC_RUN_TEST_IMPL(compression) { assert_int_equal(dns_compress_init(&cctx, mctx), ISC_R_SUCCESS); dns_compress_setpermitted(&cctx, permitted); dns_compress_disable(&cctx); - dns_decompress_init(&dctx, DNS_DECOMPRESS_STRICT); - dns_decompress_setpermitted(&dctx, permitted); + dctx = dns_decompress_setpermitted(DNS_DECOMPRESS_DEFAULT, permitted); compress_test(&name1, &name2, &name3, plain, sizeof(plain), &cctx, - &dctx); + dctx); dns_compress_rollback(&cctx, 0); dns_compress_invalidate(&cctx); diff --git a/tests/dns/rdata_test.c b/tests/dns/rdata_test.c index 8549cc528b..0b6c6d73f7 100644 --- a/tests/dns/rdata_test.c +++ b/tests/dns/rdata_test.c @@ -132,7 +132,6 @@ wire_to_rdata(const unsigned char *src, size_t srclen, dns_rdataclass_t rdclass, dns_rdatatype_t type, unsigned char *dst, size_t dstlen, dns_rdata_t *rdata) { isc_buffer_t source, target; - dns_decompress_t dctx; isc_result_t result; /* @@ -150,10 +149,8 @@ wire_to_rdata(const unsigned char *src, size_t srclen, dns_rdataclass_t rdclass, /* * Try converting input data into uncompressed wire form. */ - dns_decompress_init(&dctx, DNS_DECOMPRESS_ANY); - result = dns_rdata_fromwire(rdata, rdclass, type, &source, &dctx, 0, - &target); - dns_decompress_invalidate(&dctx); + result = dns_rdata_fromwire(rdata, rdclass, type, &source, + DNS_DECOMPRESS_ALWAYS, 0, &target); return (result); }