]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Shrink decompression contexts
authorTony Finch <fanf@isc.org>
Thu, 5 May 2022 15:36:52 +0000 (16:36 +0100)
committerTony Finch <fanf@isc.org>
Wed, 1 Jun 2022 12:00:40 +0000 (13:00 +0100)
It's wasteful to use 20 bytes and a pointer indirection to represent
two bits of information, so turn the struct into an enum. And change
the names of the enumeration constants to make the intent more clear.

This change introduces some inline functions into another header,
which confuses `gcovr` when it is trying to collect code coverage
statistics. So, in the CI job, copy more header files into a directory
where `gcovr` looks for them.

54 files changed:
.gitlab-ci.yml
bin/tools/dnstap-read.c
doc/dev/rdata.md
fuzz/dns_rdata_fromwire_text.c
lib/dns/client.c
lib/dns/compress.c
lib/dns/include/dns/compress.h
lib/dns/include/dns/name.h
lib/dns/include/dns/rdata.h
lib/dns/include/dns/types.h
lib/dns/journal.c
lib/dns/master.c
lib/dns/message.c
lib/dns/name.c
lib/dns/nsec3.c
lib/dns/rdata.c
lib/dns/rdata/any_255/tsig_250.c
lib/dns/rdata/ch_3/a_1.c
lib/dns/rdata/generic/afsdb_18.c
lib/dns/rdata/generic/amtrelay_260.c
lib/dns/rdata/generic/cname_5.c
lib/dns/rdata/generic/dname_39.c
lib/dns/rdata/generic/hip_55.c
lib/dns/rdata/generic/ipseckey_45.c
lib/dns/rdata/generic/lp_107.c
lib/dns/rdata/generic/mb_7.c
lib/dns/rdata/generic/md_3.c
lib/dns/rdata/generic/mf_4.c
lib/dns/rdata/generic/mg_8.c
lib/dns/rdata/generic/minfo_14.c
lib/dns/rdata/generic/mr_9.c
lib/dns/rdata/generic/mx_15.c
lib/dns/rdata/generic/naptr_35.c
lib/dns/rdata/generic/ns_2.c
lib/dns/rdata/generic/nsec_47.c
lib/dns/rdata/generic/nxt_30.c
lib/dns/rdata/generic/proforma.c
lib/dns/rdata/generic/ptr_12.c
lib/dns/rdata/generic/rp_17.c
lib/dns/rdata/generic/rrsig_46.c
lib/dns/rdata/generic/rt_21.c
lib/dns/rdata/generic/sig_24.c
lib/dns/rdata/generic/soa_6.c
lib/dns/rdata/generic/talink_58.c
lib/dns/rdata/generic/tkey_249.c
lib/dns/rdata/in_1/a6_38.c
lib/dns/rdata/in_1/apl_42.c
lib/dns/rdata/in_1/kx_36.c
lib/dns/rdata/in_1/nsap-ptr_23.c
lib/dns/rdata/in_1/px_26.c
lib/dns/rdata/in_1/srv_33.c
lib/dns/rdata/in_1/svcb_64.c
tests/dns/name_test.c
tests/dns/rdata_test.c

index b6d7ad9d432f12115da0ee96d86d87e094f09174..db8f85bb1e14b65d7ba728905e7c94d5b901a3ad 100644 (file)
@@ -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.
index fe215715e4d5c9829217f430dcbb3e27c1ab1735..78b95a76fbbcc7753b7c45b1e2d151f80989e087 100644 (file)
@@ -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);
index 7c67650179f9d17f30ad143ebe68a964c9a3e319..f68b0b2ffee99031eca9c1791d91af5836c76a95 100644 (file)
@@ -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 |
 |---------|-----------------------|
index 3f71538b5fb985dad32668697c3ae16fd8c8e59e..5a970e3dfa7162a41a9365a28eef3be32198f09e 100644 (file)
@@ -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);
 
        /*
index cbe70337cc953ec711fb655f759ee51cb5c79e14..a5bbaebe97d0e0fae9eb55d2513f04445dfd8415 100644 (file)
@@ -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));
index 8e49f9bbce1d42304e4344161e497f7f5469126a..f195e98b064477761f43f3e7a4d84c462e3b0b6c 100644 (file)
@@ -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);
-}
index f3c6a7e12ddf51db35f644c5231ce68c3decc73d..151a860fbe4327664a8d6ad8191864ac7d0c0385 100644 (file)
@@ -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.
- */
-
-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
+/*%
+ *     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);
+       }
+}
 
-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
index 8063799490b9a653732434393ccfd5cf81733ddf..e294b9068bc09f5d87c45161c86a95fc8dd70fb7 100644 (file)
@@ -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.
index 03298c7c71b399e6f9f523cf0cdd85e47f0360fa..029685a6ef8a32aee95f494be24b50273520bbfc 100644 (file)
@@ -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.
index eece8448d3780ae8c464bac992c7bbb668506cea..4d69639f1324337bcaab729d88fd9821f7b8b1e5 100644 (file)
@@ -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;
index 9732682d03a467c67eb3ba683f069d0092dc49bb..664ef23269fba3598a7f0bf4bf20c17e4ae158b3 100644 (file)
@@ -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;
index ccedc1af842c116c6603ae1907c14c87a976553c..598bde02de6a09c556f0397f830049fba2242261 100644 (file)
@@ -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;
                        }
index e567202eb94aae5a23a14f69cca47517f1a54b36..da101eeadcd72bbb8fdeaf15478b6bd5800dc811 100644 (file)
@@ -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;
        }
index 76dd6b4470a0cec829e621f76508c47702413cdc..26114fde3006aecf09ad741af27bcbaa2e2ce1f6 100644 (file)
@@ -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;
index 5644f1e9e7f7690923e76d0d4d07622c4a5bea1d..fca6459343036eeb2c31db9bae5a06c2f68e2d4f 100644 (file)
@@ -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);
 }
index 44e3030723ad026a5cba753f99cfca6e11e94667..23c863edbb6a49f9fc2ad244d8171d5f04fbe185 100644 (file)
@@ -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);
 }
index f6829c67c2f43a45ff9a47d8bddcfdce6cb8d920..3dbd73349bb146962ad71fddd200c29c5337e04c 100644 (file)
@@ -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.
index b5514c1659257cad066c0099bedfb59d7ea99524..09051af0cc513338cce8c6f7bfd2f2349019ada1 100644 (file)
@@ -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);
 
index 63b3149cd674a65dbea4f67f2b8956e3956b38ff..3b2404847925af96e0065c6392f315dc3b267485 100644 (file)
@@ -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);
 
index 13b707cf8226231b0f1bb4e579eaadccfb739cf7..616c6ff2a6b0f1fe590d5d00d7d150239f147aaa 100644 (file)
@@ -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, &region);
        if (region.length < 2) {
index 61b2e9f278605275ffd9bf4fc83136928c9b2940..3cc6918c5253c5b4d2eda4e5a8f5390f6443ccf6 100644 (file)
@@ -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));
index cd7a0d8f7523e9134a429e673df81a8ad547752b..b061ccb13a4f81ea5d0d398409f213fa3e407790 100644 (file)
@@ -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));
index 34d7940faaa2e819bbf6ef70e2eb385f68d204db..041f561d3e9c9429e0e98b19bc91cf9a948f2f21 100644 (file)
@@ -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));
index 5122ebe1d2b6604fedacbe2cb3b5d774cff56886..c69280d79f16e30d1bbc538e2e810418a2230221 100644 (file)
@@ -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);
 
index 91658938ce6801548937258c5892553f5bda4e30..d02e4aa00d019545f9dddf4eef4261c182b2219a 100644 (file)
@@ -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);
 
index 4d417ded87b83555b796b1c7691d3b1830d8c1ee..64e3ed32362f9acb0ee20cab0344c6ff74f81127 100644 (file)
@@ -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));
index 7711eac08407c25ae86b7978ffed05094798ac0d..e817ac03388550d6c07e341253a27566aa0bee85 100644 (file)
@@ -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));
index 5130e5006afecc10a6d70f8e1c09e44ad4d76b1b..e28878f3345cab92bf5f714e5d1726d70c778888 100644 (file)
@@ -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));
index 7285c5cb3645f2530813de4fcee73a690a3f5a61..60c85c3ba807fc38197c73a5cfe6b846359d155b 100644 (file)
@@ -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));
index 03200ba9d94fc8f0ed0e76193e9feb238346dac1..3ccf77a0999fc3b536ba43637420c670a881b3fe 100644 (file)
@@ -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);
index 60f59cacf6d3fa743bd7e3047f7de602cb4c191a..5fc77963d46b54c5d6f4f8ddb4408fbd9763d455 100644 (file)
@@ -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));
index 4614c95ac53371e1cd3242662ea0f20549f6fe30..a914540ccce825ea52089d5a7a098f0578ffa9f6 100644 (file)
@@ -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);
 
index afa1a5d4b8d8f28a98da62562b460ea9d0ff887d..5babd31b93152573dbaedc0c0401935ffd4829bd 100644 (file)
@@ -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);
 
index ce9f44a11244f98800f770871b40c0db6de2861b..32b543065695de91f5fc73a26f0e87f36cf2c54c 100644 (file)
@@ -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));
index 571a0ce37be660b457846f2814afd7c417df7ce9..e36ff655520895933f07fad9a8c2a33949a26ac8 100644 (file)
@@ -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));
index 5dce8a03fca75fb56e576467d064de50a55fbe20..7d62c56a7445bb5aa208a9e386d5f76531e403ad 100644 (file)
@@ -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));
index 2c286227b0e5b1fd120410e347eaaaed0726e0a1..fa7982fb7a8086923f0c9a103b3d49decdda67e5 100644 (file)
@@ -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);
 }
index f584b7a80eb148fc84c7e58659712f41d1e91681..8acffe797e406d2338ac8ed4ba4cf60f94040ddb 100644 (file)
@@ -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));
index 6e1800d7cd30c79bafba6794b068385149d61074..dfba5feca9299d36d21937fc626bf71b69d12dff 100644 (file)
@@ -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);
index d457160b0457af406434f7420bc4d57042515189..0aba846913f5843d3f4262a1a57d69a346f4f1d4 100644 (file)
@@ -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);
        /*
index f36836f3ab597ab0b197f4284d40d1baf76621d7..a22ff600d724d5e3ae4b7e1a1797cdafcaa1ff93 100644 (file)
@@ -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);
 
index f6a10f7a44938211c9c50502d66b3ddbe662094a..1d4b6f7bc03ce76a40845170cc9156215c87bcae 100644 (file)
@@ -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);
        /*
index 2cba492c77b8a98226a45a45bb1c6a893b4d3d5c..e72ff5cc40e07b6542ce83ccfb3dde9c036f4641 100644 (file)
@@ -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);
index b47220f0b99f5f82f6327c3a6045bfc95ba35420..710efb5a98cd3b8e847732da2d4cabe63830dac4 100644 (file)
@@ -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);
index 34189cf0822aa58827ff6003f64f02d43d37bbd1..a77054da11152886051654946e6908cbd8557ace 100644 (file)
@@ -253,7 +253,7 @@ fromwire_tkey(ARGS_FROMWIRE) {
        UNUSED(type);
        UNUSED(rdclass);
 
-       dns_decompress_setpermitted(dctx, false);
+       dctx = dns_decompress_setpermitted(dctx, false);
 
        /*
         * Algorithm.
index ea2f13fe9b5c22c3c78177205388d1ea2eef10d6..83716952aa02cb9a9965f5f8c4f5bad4745ef456 100644 (file)
@@ -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);
        /*
index c2862d3f1ce0625fb1e265b1f2ca6b0a3b0b39b6..d7f12f962fae2a69d694b6bc82e9c33f0d8563f6 100644 (file)
@@ -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
index 355734332d45156d87a706c53d28074ca8d20cab..9a271b9c706caed55f9a34413f4316614bb86ebf 100644 (file)
@@ -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);
 
index 3345aa82c9031fa3e73a4c8965f6d6c87b4d395a..a3cb908ca755d5f1a0a8a4bc95e1343b881ad903 100644 (file)
@@ -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));
index 1223664153834fdd8c20c5c93126a604bee11193..8f5af8783a150a199fef0c6e3ddad35747a0784b 100644 (file)
@@ -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);
 
index df10c819d8e2f5bda2014e645793d331157a1834..da07c9598637f95694a52a610a7009aa636c5d4f 100644 (file)
@@ -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);
 
index 00fdf24b250a19c3a9cca9b70d693bb9aba0fe3d..ed9d2d6537ce981be4837be25553746bb5746bb3 100644 (file)
@@ -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);
 
index 4bb4655914af1db9d950e9bfd40e01a549f4b80e..2eeaa4bf69fb6839e7c9ce818ba4c77acb124ae9 100644 (file)
@@ -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);
index 8549cc528b49ea178e745774306b4a95f1375735..0b6c6d73f712f1227f1faff03e57bbe8ec313c13 100644 (file)
@@ -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);
 }