mirror of
https://github.com/isc-projects/bind9.git
synced 2026-07-16 13:33:38 -04:00
Merge branch 'fanf-compression-relic' into 'main'
Clean up the dns_compress API See merge request isc-projects/bind9!6270
This commit is contained in:
commit
f2dafeba60
70 changed files with 291 additions and 766 deletions
|
|
@ -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.
|
||||
|
|
|
|||
7
CHANGES
7
CHANGES
|
|
@ -1,3 +1,10 @@
|
|||
5898. [cleanup] Simplify BIND's internal DNS name compression API. As
|
||||
RFC 6891 explains, it isn't practical to deploy new
|
||||
label types or compression methods, so it isn't
|
||||
necessary to have an API designed to support them.
|
||||
Remove compression terminology that refers to Internet
|
||||
Drafts that expired in the 1990s. [GL !6270]
|
||||
|
||||
5897. [bug] Views that weren't configured to use RFC 5011 key
|
||||
management would still set up an empty managed-keys
|
||||
zone. This has been fixed. [GL #3349]
|
||||
|
|
|
|||
|
|
@ -2442,7 +2442,7 @@ setup_lookup(dig_lookup_t *lookup) {
|
|||
|
||||
lookup->sendspace = isc_mem_get(mctx, COMMSIZE);
|
||||
|
||||
result = dns_compress_init(&cctx, -1, mctx);
|
||||
result = dns_compress_init(&cctx, mctx);
|
||||
check_result(result, "dns_compress_init");
|
||||
|
||||
debug("starting to render the message");
|
||||
|
|
@ -3053,7 +3053,9 @@ failure_tls:
|
|||
} else {
|
||||
next = NULL;
|
||||
}
|
||||
query_detach(&connectquery);
|
||||
if (connectquery != NULL) {
|
||||
query_detach(&connectquery);
|
||||
}
|
||||
query_detach(&query);
|
||||
if (next == NULL) {
|
||||
clear_current_lookup();
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ process_message(isc_buffer_t *source) {
|
|||
message->counts[i] = 0; /* Another hack XXX */
|
||||
}
|
||||
|
||||
result = dns_compress_init(&cctx, -1, mctx);
|
||||
result = dns_compress_init(&cctx, mctx);
|
||||
CHECKRESULT(result, "dns_compress_init() failed");
|
||||
|
||||
result = dns_message_renderbegin(message, &cctx, &buffer);
|
||||
|
|
|
|||
|
|
@ -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, -1, 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);
|
||||
|
|
|
|||
|
|
@ -1,159 +0,0 @@
|
|||
<!--
|
||||
Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
|
||||
SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
See the COPYRIGHT file distributed with this work for additional
|
||||
information regarding copyright ownership.
|
||||
-->
|
||||
|
||||
Name Compression
|
||||
|
||||
Overview.
|
||||
|
||||
BIND 4.x and BIND 8.x only had one methods of compression to deal
|
||||
with 14 bit compression. BIND 9 has 3 methods of compression
|
||||
to deal with 14 bit, 16 bit and local compression (14 and 16 bit).
|
||||
|
||||
In addition to this the allowed compression methods vary across
|
||||
types and across client revisions thanks to EDNS.
|
||||
|
||||
To be able to compress a domain name you need to some or all of
|
||||
the following pieces of information.
|
||||
|
||||
1. where the message starts.
|
||||
2. where the current rdata starts in the message (local compression).
|
||||
3. what the current owner name is (local compression).
|
||||
4. existing global 14 bit compression targets.
|
||||
5. existing global 16 bit compression targets.
|
||||
6. existing local compression targets.
|
||||
7. the current domain name.
|
||||
8. what are allowable compression methods, these are not constant
|
||||
across a message.
|
||||
|
||||
BIND 4.x and BIND 8.x used a table of existing 14 bit compression
|
||||
targets.
|
||||
|
||||
The implicit assumption is that we will use compression whenever
|
||||
possible and when ever there are multiple alternatives available
|
||||
we will choose the one that minimises the size of the message.
|
||||
|
||||
We will need functions that determine the allowable compression
|
||||
methods, find the "best" match among the available compression
|
||||
targets, add new compression targets.
|
||||
|
||||
We need to be able to back out any changes made to the compression
|
||||
targets if we are unable to add a complete RR (RRset?). This is
|
||||
only a problem for the global compression targets.
|
||||
|
||||
Implementation:
|
||||
|
||||
We will maintain two RBT, one for local compression targets and
|
||||
one for global compression targets. The data for these RBT will
|
||||
be the offset values. The local compression RBT only needs to
|
||||
be maintained when local compression is possible. The global
|
||||
compression RBT is maintained regardless. Unless there is a
|
||||
perfect match (or the name is ".") we will add the name to the
|
||||
compression RBTs provide the offset would not be too large for
|
||||
the valid compression methods of the RBT. All nodes of the RBT
|
||||
will have an offset excluding the root node.
|
||||
|
||||
The local compression RBT will be initialised with the owner name
|
||||
and the start of the rdata will be recorded.
|
||||
|
||||
We will use deepest partial match to find the potential
|
||||
compression targets.
|
||||
|
||||
We only need to maintain one global RBT as 16 bit compression
|
||||
pointers are either valid or invalid for the whole message.
|
||||
|
||||
dns_rdata_towire() will set the allowed methods based on the
|
||||
edns version.
|
||||
|
||||
Functions:
|
||||
|
||||
dns_result_t
|
||||
dns_compress_init(dns_compress_t *cctx, int edns, isc_mem_t *mctx);
|
||||
|
||||
Initialises cctx to empty and sets whether 16 bit global
|
||||
compression targets are to be added to the global RBT based on the
|
||||
edns value.
|
||||
|
||||
dns_result_t
|
||||
dns_compress_localinit(dns_compress_t *cctx, dns_name_t *owner,
|
||||
isc_buffer_t *target);
|
||||
|
||||
Initialise a RBT for local compression, freeing and existing RBT.
|
||||
Record current offset.
|
||||
|
||||
dns_compress_invalidate(dns_compress_t *cctx);
|
||||
|
||||
Free any RBT's and make empty.
|
||||
|
||||
dns_compress_localinvalidate(dns_compress_t *cctx);
|
||||
|
||||
Free the local RBT.
|
||||
|
||||
void
|
||||
dns_compress_setmethods(dns_compress_t *cctx, unsigned int allowed);
|
||||
|
||||
unsigned int
|
||||
dns_compress_getmethods(dns_compress_t *cctx);
|
||||
|
||||
int
|
||||
dns_compress_getedns(dns_compress_t *cctx);
|
||||
|
||||
dns_result_t
|
||||
dns_name_towire(dns_name_t *name, dns_compress_t *cctx,
|
||||
isc_buffer_t *target);
|
||||
|
||||
'name' contains the current name to be added to the message 'target'.
|
||||
'target' is assumed to only contain the message.
|
||||
'cctx' contains the compression context and has to hold all the
|
||||
information required that cannot be obtained from 'name' or 'target'.
|
||||
|
||||
struct dns_compress {
|
||||
unsigned int allowed; /* Allowed methods. */
|
||||
unsigned int rdata; /* Start of local rdata */
|
||||
bool global16; /* 16 bit offsets allowed */
|
||||
dns_rbt_t *local; /* Local RBT */
|
||||
dns_rbt_t *global; /* Global RBT */
|
||||
isc_mem_t *mctx; /* Required by RBT */
|
||||
};
|
||||
|
||||
sets allowed based on the value of edns.
|
||||
|
||||
bool
|
||||
dns_compress_findglobal(dns_compress_t *cctx, dns_name_t *name,
|
||||
dns_name_t *prefix, dns_name_t *suffix,
|
||||
uint16_t *offset, isc_buffer_t *workspace);
|
||||
|
||||
bool
|
||||
dns_compress_findlocal(dns_compress_t *cctx, dns_name_t *name,
|
||||
dns_name_t *prefix, dns_name_t *suffix,
|
||||
uint16_t *offset, isc_buffer_t *workspace);
|
||||
|
||||
Find the best best match in the global / local RBT. Returns prefix,
|
||||
suffix and offset of the bestmatch. Findglobal(), findlocal()
|
||||
requires as workspace as it may be necessary to spit a bit stream
|
||||
label. The result prefix will be such that it can be added to the
|
||||
wire format followed by a compression pointer pointing to offset.
|
||||
Suffix is returned so that it is possible to add the compression
|
||||
pointers via dns_compress_add().
|
||||
|
||||
void
|
||||
dns_compress_add(dns_compress_t *cctx, dns_name_t *prefix,
|
||||
dns_name_t *suffix, uint16_t offset);
|
||||
|
||||
Add compression pointers pointing to lebels (if any) in prefix.
|
||||
The offset to the first label is passed in offset.
|
||||
|
||||
Dependency:
|
||||
|
||||
Requires RBT deepest match.
|
||||
Requires the ability to walk the RBT and remove any node which
|
||||
meets the removal condition.
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
<!--
|
||||
Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
|
||||
SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
See the COPYRIGHT file distributed with this work for additional
|
||||
information regarding copyright ownership.
|
||||
-->
|
||||
|
||||
Name Decompression
|
||||
|
||||
Overview.
|
||||
|
||||
There are 4 type of compression: global 14 bit, global 16 bit,
|
||||
local 14 bit and local 16 bit.
|
||||
|
||||
In general the resolver / nameserver should accept any compression
|
||||
method at any time regardless of whether it was legal to
|
||||
send it. This fits with the principle of being liberal with
|
||||
what you accept and strict with what you send.
|
||||
|
||||
There are a few cases where it does not make sense to accept
|
||||
compression pointers of a given type. i.e. the first domain name
|
||||
in a message, local compression pointers in the ownername of a RR
|
||||
or in a question.
|
||||
|
||||
When performing regression testing however we should be as strict
|
||||
as possible. Hence we need to be able modify the behaviour of the
|
||||
decompression routines.
|
||||
|
||||
To be able to decompress a domain name we need some or all of the
|
||||
following pieces of information.
|
||||
|
||||
1. where the message starts.
|
||||
2. where the current rdata starts in the message (local compression).
|
||||
3. what the current owner name is (local compression).
|
||||
4. where the domainname we are decompressing starts.
|
||||
5. what are allowable decompression method. These vary across type
|
||||
and edn version.
|
||||
|
||||
Implementation:
|
||||
|
||||
dns_rdata_fromwire will set the allowed decompression methods allowed
|
||||
by looking at edns, strict and the type values.
|
||||
|
||||
Types:
|
||||
struct dns_decompress {
|
||||
unsigned int magic;
|
||||
unsigned int allowed;
|
||||
int edns;
|
||||
dns_name_t owner_name;
|
||||
unsigned int rdata;
|
||||
bool strict;
|
||||
}
|
||||
|
||||
Functions:
|
||||
|
||||
void
|
||||
dns_decompress_init(dns_decompress_t *dctx, int edns,
|
||||
bool strict);
|
||||
initialise dctx
|
||||
dctx->ownername is invalidated
|
||||
|
||||
void
|
||||
dns_decompress_localinit(dns_decompress_t *dctx, dns_name_t *name,
|
||||
isc_buffer_t *source);
|
||||
initialise dctx->ownername
|
||||
record source->current to dctx->rdata
|
||||
|
||||
void
|
||||
dns_decompress_invalidate(dns_decompress_t *dctx);
|
||||
|
||||
invalidate dctx
|
||||
|
||||
void
|
||||
dns_decompress_localinvalidate(dns_decompress_t *dctx);
|
||||
|
||||
invalidate dctx->ownername
|
||||
|
||||
void
|
||||
dns_decompress_setmethods(dns_decompress_t *dctx, unsigned int allowed);
|
||||
|
||||
sets dctx->allowed
|
||||
|
||||
unsigned int
|
||||
dns_decompress_getmethods(dns_decompress_t *dctx);
|
||||
|
||||
returns dctx->allowed
|
||||
|
||||
int
|
||||
dns_decompress_edns(dns_decompress_t *dctx);
|
||||
|
||||
returns dctx->edns
|
||||
|
||||
bool
|
||||
dns_decompress_strict(dns_decompress_t *dctx);
|
||||
|
||||
returns dctx->strict
|
||||
|
||||
dns_result_t
|
||||
dns_name_fromwire(dns_name_t *name, isc_buffer_t *source,
|
||||
dns_decompress_t *dctx, bool downcase,
|
||||
isc_buffer_t *target)
|
||||
|
|
@ -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,17 +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 the valid
|
||||
decompression methods if there is a domain name in the rdata.
|
||||
`fromwire_classname_typename()` is required to set whether
|
||||
name compression is allowed, according to RFC 3597.
|
||||
|
||||
if (dns_decompress_edns(dctx) >= # || !dns_decompress_strict(dctx))
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL);
|
||||
else
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
|
||||
dctx = dns_decompress_setpermitted(dctx, true); /* or false */
|
||||
|
||||
|Parameter|Description |
|
||||
|---------|-----------------------|
|
||||
|
|
@ -245,14 +242,10 @@ will return `DNS_R_EXTRADATA`.
|
|||
dns_compress_t *cctx,
|
||||
isc_buffer_t *target);
|
||||
|
||||
`towire_classname_typename()` is required to set the
|
||||
allowed name compression methods based on the EDNS version, if there
|
||||
is a domain name in the rdata.
|
||||
`towire_classname_typename()` is required to set whether
|
||||
name compression is allowed, according to RFC 3597.
|
||||
|
||||
if (dns_compress_getedns(cctx) >= #)
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
|
||||
else
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
|
||||
dns_compress_setpermitted(cctx, true); /* or false */
|
||||
|
||||
|Parameter|Description |
|
||||
|---------|-----------------------|
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ render_message(dns_message_t **messagep) {
|
|||
message->counts[i] = 0;
|
||||
}
|
||||
|
||||
result = dns_compress_init(&cctx, -1, mctx);
|
||||
result = dns_compress_init(&cctx, mctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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, -1, 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);
|
||||
|
||||
/*
|
||||
|
|
@ -206,7 +203,7 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||
/*
|
||||
* Convert rdata back to wire.
|
||||
*/
|
||||
CHECK(dns_compress_init(&cctx, -1, mctx));
|
||||
CHECK(dns_compress_init(&cctx, mctx));
|
||||
dns_compress_disable(&cctx);
|
||||
isc_buffer_init(&target, towire, sizeof(towire));
|
||||
result = dns_rdata_towire(&rdata1, &cctx, &target);
|
||||
|
|
|
|||
|
|
@ -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, -1, 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));
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
@ -123,14 +120,18 @@ static unsigned char tableindex[256] = {
|
|||
***/
|
||||
|
||||
isc_result_t
|
||||
dns_compress_init(dns_compress_t *cctx, int edns, isc_mem_t *mctx) {
|
||||
dns_compress_init(dns_compress_t *cctx, isc_mem_t *mctx) {
|
||||
REQUIRE(cctx != NULL);
|
||||
REQUIRE(mctx != NULL); /* See: rdataset.c:towiresorted(). */
|
||||
|
||||
cctx->edns = edns;
|
||||
/*
|
||||
* not using a structure literal here to avoid large memset()s
|
||||
*/
|
||||
cctx->mctx = mctx;
|
||||
cctx->count = 0;
|
||||
cctx->allowed = DNS_COMPRESS_ENABLED;
|
||||
cctx->permitted = true;
|
||||
cctx->disabled = false;
|
||||
cctx->sensitive = false;
|
||||
cctx->arena_off = 0;
|
||||
|
||||
memset(&cctx->table[0], 0, sizeof(cctx->table));
|
||||
|
|
@ -163,52 +164,39 @@ dns_compress_invalidate(dns_compress_t *cctx) {
|
|||
}
|
||||
|
||||
cctx->magic = 0;
|
||||
cctx->allowed = 0;
|
||||
cctx->edns = -1;
|
||||
cctx->permitted = false;
|
||||
cctx->disabled = false;
|
||||
cctx->sensitive = false;
|
||||
}
|
||||
|
||||
void
|
||||
dns_compress_setmethods(dns_compress_t *cctx, unsigned int allowed) {
|
||||
dns_compress_setpermitted(dns_compress_t *cctx, bool permitted) {
|
||||
REQUIRE(VALID_CCTX(cctx));
|
||||
|
||||
cctx->allowed &= ~DNS_COMPRESS_ALL;
|
||||
cctx->allowed |= (allowed & DNS_COMPRESS_ALL);
|
||||
cctx->permitted = permitted;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
dns_compress_getmethods(dns_compress_t *cctx) {
|
||||
bool
|
||||
dns_compress_getpermitted(dns_compress_t *cctx) {
|
||||
REQUIRE(VALID_CCTX(cctx));
|
||||
return (cctx->allowed & DNS_COMPRESS_ALL);
|
||||
return (cctx->permitted);
|
||||
}
|
||||
|
||||
void
|
||||
dns_compress_disable(dns_compress_t *cctx) {
|
||||
REQUIRE(VALID_CCTX(cctx));
|
||||
cctx->allowed &= ~DNS_COMPRESS_ENABLED;
|
||||
cctx->disabled = true;
|
||||
}
|
||||
|
||||
void
|
||||
dns_compress_setsensitive(dns_compress_t *cctx, bool sensitive) {
|
||||
REQUIRE(VALID_CCTX(cctx));
|
||||
|
||||
if (sensitive) {
|
||||
cctx->allowed |= DNS_COMPRESS_CASESENSITIVE;
|
||||
} else {
|
||||
cctx->allowed &= ~DNS_COMPRESS_CASESENSITIVE;
|
||||
}
|
||||
cctx->sensitive = sensitive;
|
||||
}
|
||||
|
||||
bool
|
||||
dns_compress_getsensitive(dns_compress_t *cctx) {
|
||||
REQUIRE(VALID_CCTX(cctx));
|
||||
|
||||
return (cctx->allowed & DNS_COMPRESS_CASESENSITIVE);
|
||||
}
|
||||
|
||||
int
|
||||
dns_compress_getedns(dns_compress_t *cctx) {
|
||||
REQUIRE(VALID_CCTX(cctx));
|
||||
return (cctx->edns);
|
||||
return (cctx->sensitive);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -217,8 +205,8 @@ dns_compress_getedns(dns_compress_t *cctx) {
|
|||
* If no match is found return false.
|
||||
*/
|
||||
bool
|
||||
dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name,
|
||||
dns_name_t *prefix, uint16_t *offset) {
|
||||
dns_compress_find(dns_compress_t *cctx, const dns_name_t *name,
|
||||
dns_name_t *prefix, uint16_t *offset) {
|
||||
dns_name_t tname;
|
||||
dns_compressnode_t *node = NULL;
|
||||
unsigned int labels, i, n;
|
||||
|
|
@ -229,7 +217,7 @@ dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name,
|
|||
REQUIRE(dns_name_isabsolute(name));
|
||||
REQUIRE(offset != NULL);
|
||||
|
||||
if ((cctx->allowed & DNS_COMPRESS_ENABLED) == 0) {
|
||||
if (cctx->disabled) {
|
||||
return (false);
|
||||
}
|
||||
|
||||
|
|
@ -258,7 +246,7 @@ dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name,
|
|||
*/
|
||||
ch = p[1];
|
||||
i = tableindex[ch];
|
||||
if ((cctx->allowed & DNS_COMPRESS_CASESENSITIVE) != 0) {
|
||||
if (cctx->sensitive) {
|
||||
for (node = cctx->table[i]; node != NULL;
|
||||
node = node->next) {
|
||||
if (node->name.length != length) {
|
||||
|
|
@ -388,7 +376,7 @@ dns_compress_add(dns_compress_t *cctx, const dns_name_t *name,
|
|||
REQUIRE(VALID_CCTX(cctx));
|
||||
REQUIRE(dns_name_isabsolute(name));
|
||||
|
||||
if ((cctx->allowed & DNS_COMPRESS_ENABLED) == 0) {
|
||||
if (cctx->disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -489,7 +477,7 @@ dns_compress_rollback(dns_compress_t *cctx, uint16_t offset) {
|
|||
|
||||
REQUIRE(VALID_CCTX(cctx));
|
||||
|
||||
if ((cctx->allowed & DNS_COMPRESS_ENABLED) == 0) {
|
||||
if (cctx->disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -515,64 +503,3 @@ dns_compress_rollback(dns_compress_t *cctx, uint16_t offset) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
*** Decompression
|
||||
***/
|
||||
|
||||
void
|
||||
dns_decompress_init(dns_decompress_t *dctx, int edns,
|
||||
dns_decompresstype_t type) {
|
||||
REQUIRE(dctx != NULL);
|
||||
REQUIRE(edns >= -1 && edns <= 255);
|
||||
|
||||
dctx->allowed = DNS_COMPRESS_NONE;
|
||||
dctx->edns = edns;
|
||||
dctx->type = type;
|
||||
dctx->magic = DCTX_MAGIC;
|
||||
}
|
||||
|
||||
void
|
||||
dns_decompress_invalidate(dns_decompress_t *dctx) {
|
||||
REQUIRE(VALID_DCTX(dctx));
|
||||
|
||||
dctx->magic = 0;
|
||||
}
|
||||
|
||||
void
|
||||
dns_decompress_setmethods(dns_decompress_t *dctx, unsigned int allowed) {
|
||||
REQUIRE(VALID_DCTX(dctx));
|
||||
|
||||
switch (dctx->type) {
|
||||
case DNS_DECOMPRESS_ANY:
|
||||
dctx->allowed = DNS_COMPRESS_ALL;
|
||||
break;
|
||||
case DNS_DECOMPRESS_NONE:
|
||||
dctx->allowed = DNS_COMPRESS_NONE;
|
||||
break;
|
||||
case DNS_DECOMPRESS_STRICT:
|
||||
dctx->allowed = allowed;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int
|
||||
dns_decompress_getmethods(dns_decompress_t *dctx) {
|
||||
REQUIRE(VALID_DCTX(dctx));
|
||||
|
||||
return (dctx->allowed);
|
||||
}
|
||||
|
||||
int
|
||||
dns_decompress_edns(dns_decompress_t *dctx) {
|
||||
REQUIRE(VALID_DCTX(dctx));
|
||||
|
||||
return (dctx->edns);
|
||||
}
|
||||
|
||||
dns_decompresstype_t
|
||||
dns_decompress_type(dns_decompress_t *dctx) {
|
||||
REQUIRE(VALID_DCTX(dctx));
|
||||
|
||||
return (dctx->type);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,24 +27,15 @@ ISC_LANG_BEGINDECLS
|
|||
/*! \file dns/compress.h
|
||||
* Direct manipulation of the structures is strongly discouraged.
|
||||
*
|
||||
* A name compression context handles compression of multiple DNS names
|
||||
* in relation to a single DNS message. The context can be used to
|
||||
* selectively turn on/off compression for specific names (depending on
|
||||
* the RR type) by using \c dns_compress_setmethods(). Alternately,
|
||||
* compression can be disabled completely using \c
|
||||
* dns_compress_disable().
|
||||
* A name compression context handles compression of multiple DNS names in
|
||||
* relation to a single DNS message. The context can be used to selectively
|
||||
* turn on/off compression for specific names (depending on the RR type,
|
||||
* according to RFC 3597) by using \c dns_compress_setpermitted().
|
||||
*
|
||||
* \c dns_compress_setmethods() is intended for use by RDATA towire()
|
||||
* implementations, whereas \c dns_compress_disable() is intended to be
|
||||
* used by a nameserver's configuration manager.
|
||||
* The nameserver can be configured not to use compression at all using
|
||||
* \c dns_compress_disable().
|
||||
*/
|
||||
|
||||
#define DNS_COMPRESS_NONE 0x00 /*%< no compression */
|
||||
#define DNS_COMPRESS_GLOBAL14 0x01 /*%< "normal" compression. */
|
||||
#define DNS_COMPRESS_ALL 0x01 /*%< all compression. */
|
||||
#define DNS_COMPRESS_CASESENSITIVE 0x02 /*%< case sensitive compression. */
|
||||
#define DNS_COMPRESS_ENABLED 0x04
|
||||
|
||||
/*
|
||||
* DNS_COMPRESS_TABLESIZE must be a power of 2. The compress code
|
||||
* utilizes this assumption.
|
||||
|
|
@ -66,10 +57,11 @@ struct dns_compressnode {
|
|||
};
|
||||
|
||||
struct dns_compress {
|
||||
unsigned int magic; /*%< Magic number. */
|
||||
unsigned int allowed; /*%< Allowed methods. */
|
||||
int edns; /*%< Edns version or -1. */
|
||||
/*% Global compression table. */
|
||||
unsigned int magic; /*%< Magic number. */
|
||||
bool permitted;
|
||||
bool disabled;
|
||||
bool sensitive;
|
||||
/*% Compression pointer table. */
|
||||
dns_compressnode_t *table[DNS_COMPRESS_TABLESIZE];
|
||||
/*% Preallocated arena for names. */
|
||||
unsigned char arena[DNS_COMPRESS_ARENA_SIZE];
|
||||
|
|
@ -80,21 +72,15 @@ 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. */
|
||||
unsigned int allowed; /*%< Allowed methods. */
|
||||
int edns; /*%< Edns version or -1. */
|
||||
dns_decompresstype_t type; /*%< Strict checking */
|
||||
enum dns_decompress {
|
||||
DNS_DECOMPRESS_DEFAULT,
|
||||
DNS_DECOMPRESS_PERMITTED,
|
||||
DNS_DECOMPRESS_NEVER,
|
||||
DNS_DECOMPRESS_ALWAYS,
|
||||
};
|
||||
|
||||
isc_result_t
|
||||
dns_compress_init(dns_compress_t *cctx, int edns, isc_mem_t *mctx);
|
||||
dns_compress_init(dns_compress_t *cctx, isc_mem_t *mctx);
|
||||
/*%<
|
||||
* Initialise the compression context structure pointed to by
|
||||
* 'cctx'. A freshly initialized context has name compression
|
||||
|
|
@ -105,7 +91,8 @@ dns_compress_init(dns_compress_t *cctx, int edns, isc_mem_t *mctx);
|
|||
* \li 'cctx' is a valid dns_compress_t structure.
|
||||
* \li 'mctx' is an initialized memory context.
|
||||
* Ensures:
|
||||
* \li cctx->global is initialized.
|
||||
* \li 'cctx' is initialized.
|
||||
* \li 'cctx->permitted' is true.
|
||||
*
|
||||
* Returns:
|
||||
* \li #ISC_R_SUCCESS
|
||||
|
|
@ -122,17 +109,17 @@ dns_compress_invalidate(dns_compress_t *cctx);
|
|||
*/
|
||||
|
||||
void
|
||||
dns_compress_setmethods(dns_compress_t *cctx, unsigned int allowed);
|
||||
dns_compress_setpermitted(dns_compress_t *cctx, bool permitted);
|
||||
|
||||
/*%<
|
||||
* Sets allowed compression methods.
|
||||
* Sets whether compression is allowed, according to RFC 3597
|
||||
*
|
||||
* Requires:
|
||||
*\li 'cctx' to be initialized.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
dns_compress_getmethods(dns_compress_t *cctx);
|
||||
bool
|
||||
dns_compress_getpermitted(dns_compress_t *cctx);
|
||||
|
||||
/*%<
|
||||
* Gets allowed compression methods.
|
||||
|
|
@ -175,24 +162,11 @@ dns_compress_getsensitive(dns_compress_t *cctx);
|
|||
* 'cctx' to be initialized.
|
||||
*/
|
||||
|
||||
int
|
||||
dns_compress_getedns(dns_compress_t *cctx);
|
||||
|
||||
/*%<
|
||||
* Gets edns value.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'cctx' to be initialized.
|
||||
*
|
||||
* Returns:
|
||||
*\li -1 .. 255
|
||||
*/
|
||||
|
||||
bool
|
||||
dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name,
|
||||
dns_name_t *prefix, uint16_t *offset);
|
||||
dns_compress_find(dns_compress_t *cctx, const dns_name_t *name,
|
||||
dns_name_t *prefix, uint16_t *offset);
|
||||
/*%<
|
||||
* Finds longest possible match of 'name' in the global compression table.
|
||||
* Finds longest possible match of 'name' in the compression table.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'cctx' to be initialized.
|
||||
|
|
@ -201,7 +175,7 @@ dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name,
|
|||
*\li 'offset' to point to an uint16_t.
|
||||
*
|
||||
* Ensures:
|
||||
*\li 'prefix' and 'offset' are valid if true is returned.
|
||||
*\li 'prefix' and 'offset' are valid if true is returned.
|
||||
*
|
||||
* Returns:
|
||||
*\li #true / #false
|
||||
|
|
@ -221,79 +195,39 @@ dns_compress_add(dns_compress_t *cctx, const dns_name_t *name,
|
|||
* valid until the message compression is complete.
|
||||
*
|
||||
*\li 'prefix' must be a prefix returned by
|
||||
* dns_compress_findglobal(), or the same as 'name'.
|
||||
* dns_compress_find(), or the same as 'name'.
|
||||
*/
|
||||
|
||||
void
|
||||
dns_compress_rollback(dns_compress_t *cctx, uint16_t offset);
|
||||
|
||||
/*%<
|
||||
* Remove any compression pointers from global table >= offset.
|
||||
* Remove any compression pointers from the table that are >= offset.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'cctx' is initialized.
|
||||
*/
|
||||
|
||||
void
|
||||
dns_decompress_init(dns_decompress_t *dctx, int edns,
|
||||
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_setmethods(dns_decompress_t *dctx, unsigned int allowed);
|
||||
|
||||
/*%<
|
||||
* Sets 'dctx->allowed' to 'allowed'.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'dctx' to be initialized
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
dns_decompress_getmethods(dns_decompress_t *dctx);
|
||||
|
||||
/*%<
|
||||
* Returns 'dctx->allowed'
|
||||
*
|
||||
* Requires:
|
||||
*\li 'dctx' to be initialized
|
||||
*/
|
||||
|
||||
int
|
||||
dns_decompress_edns(dns_decompress_t *dctx);
|
||||
|
||||
/*%<
|
||||
* Returns 'dctx->edns'
|
||||
*
|
||||
* Requires:
|
||||
*\li 'dctx' to be initialized
|
||||
*/
|
||||
|
||||
dns_decompresstype_t
|
||||
dns_decompress_type(dns_decompress_t *dctx);
|
||||
|
||||
/*%<
|
||||
* Returns 'dctx->type'
|
||||
*
|
||||
* Requires:
|
||||
*\li 'dctx' to be initialized
|
||||
/*%
|
||||
* Returns whether decompression is allowed here
|
||||
*/
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -758,8 +757,7 @@ dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx,
|
|||
* compression context 'cctx', and storing the result in 'target'.
|
||||
*
|
||||
* Notes:
|
||||
* \li If the compression context allows global compression, then the
|
||||
* global compression table may be updated.
|
||||
* \li If compression is permitted, then the cctx table may be updated.
|
||||
*
|
||||
* Requires:
|
||||
* \li 'name' is a valid name
|
||||
|
|
@ -770,8 +768,7 @@ dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx,
|
|||
*
|
||||
* \li target is a valid buffer.
|
||||
*
|
||||
* \li Any offsets specified in a global compression table are valid
|
||||
* for buffer.
|
||||
* \li Any offsets in the compression table are valid for buffer.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -328,16 +328,14 @@ dns_rdata_towire(dns_rdata_t *rdata, dns_compress_t *cctx,
|
|||
* compression context 'cctx', and storing the result in 'target'.
|
||||
*
|
||||
* Notes:
|
||||
*\li If the compression context allows global compression, then the
|
||||
* global compression table may be updated.
|
||||
*\li If compression is permitted, then the cctx table may be updated.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'rdata' is a valid, non-empty rdata
|
||||
*
|
||||
*\li target is a valid buffer
|
||||
*
|
||||
*\li Any offsets specified in a global compression table are valid
|
||||
* for target.
|
||||
*\li Any offsets in the compression table are valid for target.
|
||||
*
|
||||
* Ensures,
|
||||
* if the result is success:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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, -1, 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;
|
||||
|
|
|
|||
|
|
@ -2342,7 +2342,7 @@ load_raw(dns_loadctx_t *lctx) {
|
|||
dns_decompress_t dctx;
|
||||
|
||||
callbacks = lctx->callbacks;
|
||||
dns_decompress_init(&dctx, -1, 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,14 +1681,9 @@ dns_message_parse(dns_message_t *msg, isc_buffer_t *source,
|
|||
msg->header_ok = 1;
|
||||
msg->state = DNS_SECTION_QUESTION;
|
||||
|
||||
/*
|
||||
* -1 means no EDNS.
|
||||
*/
|
||||
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_ANY);
|
||||
dctx = DNS_DECOMPRESS_ALWAYS;
|
||||
|
||||
dns_decompress_setmethods(&dctx, DNS_COMPRESS_GLOBAL14);
|
||||
|
||||
ret = getquestions(source, msg, &dctx, options);
|
||||
ret = getquestions(source, msg, dctx, options);
|
||||
if (ret == ISC_R_UNEXPECTEDEND && ignore_tc) {
|
||||
goto truncated;
|
||||
}
|
||||
|
|
@ -1701,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;
|
||||
}
|
||||
|
|
@ -1713,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;
|
||||
}
|
||||
|
|
@ -1725,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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
@ -1839,19 +1837,11 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source,
|
|||
}
|
||||
n = c;
|
||||
state = fw_ordinary;
|
||||
} else if (c >= 128 && c < 192) {
|
||||
/*
|
||||
* 14 bit local compression pointer.
|
||||
* Local compression is no longer an
|
||||
* IETF draft.
|
||||
*/
|
||||
return (DNS_R_BADLABELTYPE);
|
||||
} else if (c >= 192) {
|
||||
/*
|
||||
* Ordinary 14-bit pointer.
|
||||
* 14-bit compression pointer
|
||||
*/
|
||||
if ((dctx->allowed & DNS_COMPRESS_GLOBAL14) ==
|
||||
0) {
|
||||
if (!dns_decompress_getpermitted(dctx)) {
|
||||
return (DNS_R_DISALLOWED);
|
||||
}
|
||||
new_current = c & 0x3F;
|
||||
|
|
@ -1928,11 +1918,11 @@ dns_name_towire(const dns_name_t *name, dns_compress_t *cctx,
|
|||
isc_result_t
|
||||
dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx,
|
||||
isc_buffer_t *target, uint16_t *comp_offsetp) {
|
||||
unsigned int methods;
|
||||
uint16_t offset;
|
||||
dns_name_t gp; /* Global compression prefix */
|
||||
bool gf; /* Global compression target found */
|
||||
uint16_t go; /* Global compression offset */
|
||||
bool compress;
|
||||
bool found;
|
||||
uint16_t here; /* start of the name we are adding to the message */
|
||||
uint16_t there; /* target of the compression pointer */
|
||||
dns_name_t prefix;
|
||||
dns_offsets_t clo;
|
||||
dns_name_t clname;
|
||||
|
||||
|
|
@ -1945,22 +1935,20 @@ dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx,
|
|||
REQUIRE(cctx != NULL);
|
||||
REQUIRE(ISC_BUFFER_VALID(target));
|
||||
|
||||
compress = (name->attributes & DNS_NAMEATTR_NOCOMPRESS) == 0 &&
|
||||
dns_compress_getpermitted(cctx);
|
||||
|
||||
/*
|
||||
* If this exact name was already rendered before, and the
|
||||
* offset of the previously rendered name is passed to us, write
|
||||
* a compression pointer directly.
|
||||
*/
|
||||
methods = dns_compress_getmethods(cctx);
|
||||
if (comp_offsetp != NULL && *comp_offsetp < 0x4000 &&
|
||||
(name->attributes & DNS_NAMEATTR_NOCOMPRESS) == 0 &&
|
||||
(methods & DNS_COMPRESS_GLOBAL14) != 0)
|
||||
{
|
||||
if (comp_offsetp != NULL && *comp_offsetp < 0x4000 && compress) {
|
||||
if (target->length - target->used < 2) {
|
||||
return (ISC_R_NOSPACE);
|
||||
}
|
||||
offset = *comp_offsetp;
|
||||
offset |= 0xc000;
|
||||
isc_buffer_putuint16(target, offset);
|
||||
here = *comp_offsetp;
|
||||
isc_buffer_putuint16(target, here | 0xc000);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
|
@ -1973,54 +1961,52 @@ dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx,
|
|||
dns_name_clone(name, &clname);
|
||||
name = &clname;
|
||||
}
|
||||
DNS_NAME_INIT(&gp, NULL);
|
||||
DNS_NAME_INIT(&prefix, NULL);
|
||||
|
||||
offset = target->used; /*XXX*/
|
||||
here = target->used; /*XXX*/
|
||||
|
||||
if ((name->attributes & DNS_NAMEATTR_NOCOMPRESS) == 0 &&
|
||||
(methods & DNS_COMPRESS_GLOBAL14) != 0)
|
||||
{
|
||||
gf = dns_compress_findglobal(cctx, name, &gp, &go);
|
||||
if (compress) {
|
||||
found = dns_compress_find(cctx, name, &prefix, &there);
|
||||
} else {
|
||||
gf = false;
|
||||
found = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the offset is too high for 14 bit global compression, we're
|
||||
* out of luck.
|
||||
* If the offset does not fit in a 14 bit compression pointer,
|
||||
* we're out of luck.
|
||||
*/
|
||||
if (gf && go >= 0x4000) {
|
||||
gf = false;
|
||||
if (found && there >= 0x4000) {
|
||||
found = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Will the compression pointer reduce the message size?
|
||||
*/
|
||||
if (gf && (gp.length + 2) >= name->length) {
|
||||
gf = false;
|
||||
if (found && (prefix.length + 2) >= name->length) {
|
||||
found = false;
|
||||
}
|
||||
|
||||
if (gf) {
|
||||
if (target->length - target->used < gp.length) {
|
||||
if (found) {
|
||||
if (target->length - target->used < prefix.length) {
|
||||
return (ISC_R_NOSPACE);
|
||||
}
|
||||
if (gp.length != 0) {
|
||||
if (prefix.length != 0) {
|
||||
unsigned char *base = target->base;
|
||||
(void)memmove(base + target->used, gp.ndata,
|
||||
(size_t)gp.length);
|
||||
(void)memmove(base + target->used, prefix.ndata,
|
||||
(size_t)prefix.length);
|
||||
}
|
||||
isc_buffer_add(target, gp.length);
|
||||
isc_buffer_add(target, prefix.length);
|
||||
if (target->length - target->used < 2) {
|
||||
return (ISC_R_NOSPACE);
|
||||
}
|
||||
isc_buffer_putuint16(target, go | 0xc000);
|
||||
if (gp.length != 0) {
|
||||
dns_compress_add(cctx, name, &gp, offset);
|
||||
isc_buffer_putuint16(target, there | 0xc000);
|
||||
if (prefix.length != 0) {
|
||||
dns_compress_add(cctx, name, &prefix, here);
|
||||
if (comp_offsetp != NULL) {
|
||||
*comp_offsetp = offset;
|
||||
*comp_offsetp = here;
|
||||
}
|
||||
} else if (comp_offsetp != NULL) {
|
||||
*comp_offsetp = go;
|
||||
*comp_offsetp = there;
|
||||
}
|
||||
} else {
|
||||
if (target->length - target->used < name->length) {
|
||||
|
|
@ -2032,9 +2018,9 @@ dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx,
|
|||
(size_t)name->length);
|
||||
}
|
||||
isc_buffer_add(target, name->length);
|
||||
dns_compress_add(cctx, name, name, offset);
|
||||
dns_compress_add(cctx, name, name, here);
|
||||
if (comp_offsetp != NULL) {
|
||||
*comp_offsetp = offset;
|
||||
*comp_offsetp = here;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ dns_ncache_towire(dns_rdataset_t *rdataset, dns_compress_t *cctx,
|
|||
/*
|
||||
* Write the name.
|
||||
*/
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
|
||||
dns_compress_setpermitted(cctx, true);
|
||||
result = dns_name_towire(&name, cctx, target);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto rollback;
|
||||
|
|
|
|||
|
|
@ -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, -1, 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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, -1, 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, -1, 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ fromwire_any_tsig(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
/*
|
||||
* Algorithm Name.
|
||||
|
|
@ -330,7 +330,7 @@ towire_any_tsig(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->rdclass == dns_rdataclass_any);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(cctx, false);
|
||||
dns_rdata_toregion(rdata, &sr);
|
||||
dns_name_init(&name, offsets);
|
||||
dns_name_fromregion(&name, &sr);
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ fromwire_ch_a(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
|
||||
dctx = dns_decompress_setpermitted(dctx, true);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
|
||||
|
|
@ -138,7 +138,7 @@ towire_ch_a(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->rdclass == dns_rdataclass_ch);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
|
||||
dns_compress_setpermitted(cctx, true);
|
||||
|
||||
dns_name_init(&name, offsets);
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ fromwire_afsdb(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ towire_afsdb(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_afsdb);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(cctx, false);
|
||||
isc_buffer_availableregion(target, &tr);
|
||||
dns_rdata_toregion(rdata, &sr);
|
||||
if (tr.length < 2) {
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ fromwire_amtrelay(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
isc_buffer_activeregion(source, ®ion);
|
||||
if (region.length < 2) {
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ fromwire_cname(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
|
||||
dctx = dns_decompress_setpermitted(dctx, true);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
return (dns_name_fromwire(&name, source, dctx, options, target));
|
||||
|
|
@ -86,7 +86,7 @@ towire_cname(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_cname);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
|
||||
dns_compress_setpermitted(cctx, true);
|
||||
|
||||
dns_name_init(&name, offsets);
|
||||
dns_rdata_toregion(rdata, ®ion);
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ fromwire_dname(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
return (dns_name_fromwire(&name, source, dctx, options, target));
|
||||
|
|
@ -87,7 +87,7 @@ towire_dname(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_dname);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(cctx, false);
|
||||
dns_name_init(&name, offsets);
|
||||
dns_rdata_toregion(rdata, ®ion);
|
||||
dns_name_fromregion(&name, ®ion);
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ fromwire_hip(ARGS_FROMWIRE) {
|
|||
RETERR(mem_tobuffer(target, rr.base, 4 + len));
|
||||
isc_buffer_forward(source, 4 + len);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
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));
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ fromwire_ipseckey(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ fromwire_lp(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
|
||||
dctx = dns_decompress_setpermitted(dctx, true);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ fromwire_mb(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
|
||||
dctx = dns_decompress_setpermitted(dctx, true);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
return (dns_name_fromwire(&name, source, dctx, options, target));
|
||||
|
|
@ -85,7 +85,7 @@ towire_mb(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_mb);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
|
||||
dns_compress_setpermitted(cctx, true);
|
||||
|
||||
dns_name_init(&name, offsets);
|
||||
dns_rdata_toregion(rdata, ®ion);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ fromwire_md(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
|
||||
dctx = dns_decompress_setpermitted(dctx, true);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
return (dns_name_fromwire(&name, source, dctx, options, target));
|
||||
|
|
@ -85,7 +85,7 @@ towire_md(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_md);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
|
||||
dns_compress_setpermitted(cctx, true);
|
||||
|
||||
dns_name_init(&name, offsets);
|
||||
dns_rdata_toregion(rdata, ®ion);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ fromwire_mf(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
|
||||
dctx = dns_decompress_setpermitted(dctx, true);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
return (dns_name_fromwire(&name, source, dctx, options, target));
|
||||
|
|
@ -85,7 +85,7 @@ towire_mf(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_mf);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
|
||||
dns_compress_setpermitted(cctx, true);
|
||||
|
||||
dns_name_init(&name, offsets);
|
||||
dns_rdata_toregion(rdata, ®ion);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ fromwire_mg(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
|
||||
dctx = dns_decompress_setpermitted(dctx, true);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
return (dns_name_fromwire(&name, source, dctx, options, target));
|
||||
|
|
@ -85,7 +85,7 @@ towire_mg(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_mg);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
|
||||
dns_compress_setpermitted(cctx, true);
|
||||
|
||||
dns_name_init(&name, offsets);
|
||||
dns_rdata_toregion(rdata, ®ion);
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ fromwire_minfo(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
|
||||
dctx = dns_decompress_setpermitted(dctx, true);
|
||||
|
||||
dns_name_init(&rmail, NULL);
|
||||
dns_name_init(&email, NULL);
|
||||
|
|
@ -118,7 +118,7 @@ towire_minfo(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_minfo);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
|
||||
dns_compress_setpermitted(cctx, true);
|
||||
|
||||
dns_name_init(&rmail, roffsets);
|
||||
dns_name_init(&email, eoffsets);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ fromwire_mr(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
|
||||
dctx = dns_decompress_setpermitted(dctx, true);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
return (dns_name_fromwire(&name, source, dctx, options, target));
|
||||
|
|
@ -85,7 +85,7 @@ towire_mr(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_mr);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
|
||||
dns_compress_setpermitted(cctx, true);
|
||||
|
||||
dns_name_init(&name, offsets);
|
||||
dns_rdata_toregion(rdata, ®ion);
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ fromwire_mx(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
|
||||
dctx = dns_decompress_setpermitted(dctx, true);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
|
||||
|
|
@ -156,7 +156,7 @@ towire_mx(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_mx);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
|
||||
dns_compress_setpermitted(cctx, true);
|
||||
|
||||
dns_rdata_toregion(rdata, ®ion);
|
||||
RETERR(mem_tobuffer(target, region.base, 2));
|
||||
|
|
|
|||
|
|
@ -311,7 +311,7 @@ fromwire_naptr(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
|
||||
|
|
@ -357,7 +357,7 @@ towire_naptr(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_naptr);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(cctx, false);
|
||||
/*
|
||||
* Order, preference.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ fromwire_ns(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
|
||||
dctx = dns_decompress_setpermitted(dctx, true);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
return (dns_name_fromwire(&name, source, dctx, options, target));
|
||||
|
|
@ -96,7 +96,7 @@ towire_ns(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_ns);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
|
||||
dns_compress_setpermitted(cctx, true);
|
||||
|
||||
dns_name_init(&name, offsets);
|
||||
dns_rdata_toregion(rdata, ®ion);
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ fromwire_nsec(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
RETERR(dns_name_fromwire(&name, source, dctx, options, target));
|
||||
|
|
@ -106,7 +106,7 @@ towire_nsec(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_nsec);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(cctx, false);
|
||||
dns_name_init(&name, offsets);
|
||||
dns_rdata_toregion(rdata, &sr);
|
||||
dns_name_fromregion(&name, &sr);
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ fromwire_nxt(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
RETERR(dns_name_fromwire(&name, source, dctx, options, target));
|
||||
|
|
@ -169,7 +169,7 @@ towire_nxt(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_nxt);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(cctx, false);
|
||||
dns_name_init(&name, offsets);
|
||||
dns_rdata_toregion(rdata, &sr);
|
||||
dns_name_fromregion(&name, &sr);
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ static isc_result_t fromwire_ #(ARGS_FROMWIRE) {
|
|||
REQUIRE(type == dns_rdatatype_proforma.c #);
|
||||
REQUIRE(rdclass == #);
|
||||
|
||||
/* NONE or GLOBAL14 */
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
/* see RFC 3597 */
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
return (ISC_R_NOTIMPLEMENTED);
|
||||
}
|
||||
|
|
@ -51,8 +51,8 @@ static isc_result_t towire_ #(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->rdclass == #);
|
||||
REQUIRE(rdata->length != 0); /* XXX */
|
||||
|
||||
/* NONE or GLOBAL14 */
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
||||
/* see RFC 3597 */
|
||||
dns_compress_setpermitted(cctx, false);
|
||||
|
||||
return (ISC_R_NOTIMPLEMENTED);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ fromwire_ptr(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
|
||||
dctx = dns_decompress_setpermitted(dctx, true);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
return (dns_name_fromwire(&name, source, dctx, options, target));
|
||||
|
|
@ -98,7 +98,7 @@ towire_ptr(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_ptr);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
|
||||
dns_compress_setpermitted(cctx, true);
|
||||
|
||||
dns_name_init(&name, offsets);
|
||||
dns_rdata_toregion(rdata, ®ion);
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ fromwire_rp(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
dns_name_init(&rmail, NULL);
|
||||
dns_name_init(&email, NULL);
|
||||
|
|
@ -119,7 +119,7 @@ towire_rp(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_rp);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(cctx, false);
|
||||
dns_name_init(&rmail, roffsets);
|
||||
dns_name_init(&email, eoffsets);
|
||||
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ fromwire_rrsig(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
isc_buffer_activeregion(source, &sr);
|
||||
/*
|
||||
|
|
@ -357,7 +357,7 @@ towire_rrsig(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_rrsig);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(cctx, false);
|
||||
dns_rdata_toregion(rdata, &sr);
|
||||
/*
|
||||
* type covered: 2
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ fromwire_rt(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
|
||||
|
|
@ -125,7 +125,7 @@ towire_rt(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_rt);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(cctx, false);
|
||||
isc_buffer_availableregion(target, &tr);
|
||||
dns_rdata_toregion(rdata, ®ion);
|
||||
if (tr.length < 2) {
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ fromwire_sig(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
isc_buffer_activeregion(source, &sr);
|
||||
/*
|
||||
|
|
@ -320,7 +320,7 @@ towire_sig(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_sig);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(cctx, false);
|
||||
dns_rdata_toregion(rdata, &sr);
|
||||
/*
|
||||
* type covered: 2
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ fromwire_soa(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
|
||||
dctx = dns_decompress_setpermitted(dctx, true);
|
||||
|
||||
dns_name_init(&mname, NULL);
|
||||
dns_name_init(&rname, NULL);
|
||||
|
|
@ -202,7 +202,7 @@ towire_soa(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_soa);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
|
||||
dns_compress_setpermitted(cctx, true);
|
||||
|
||||
dns_name_init(&mname, moffsets);
|
||||
dns_name_init(&rname, roffsets);
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ fromwire_talink(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
dns_name_init(&prev, NULL);
|
||||
dns_name_init(&next, NULL);
|
||||
|
|
@ -108,7 +108,7 @@ towire_talink(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_talink);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(cctx, false);
|
||||
|
||||
dns_name_init(&prev, moffsets);
|
||||
dns_name_init(&next, roffsets);
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ fromwire_tkey(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
/*
|
||||
* Algorithm.
|
||||
|
|
@ -312,7 +312,7 @@ towire_tkey(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_tkey);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(cctx, false);
|
||||
/*
|
||||
* Algorithm.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ fromwire_in_a6(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
isc_buffer_activeregion(source, &sr);
|
||||
/*
|
||||
|
|
@ -211,7 +211,7 @@ towire_in_a6(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->rdclass == dns_rdataclass_in);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(cctx, false);
|
||||
dns_rdata_toregion(rdata, &sr);
|
||||
prefixlen = sr.base[0];
|
||||
INSIST(prefixlen <= 128);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ fromwire_in_kx(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ towire_in_kx(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->rdclass == dns_rdataclass_in);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(cctx, false);
|
||||
dns_rdata_toregion(rdata, ®ion);
|
||||
RETERR(mem_tobuffer(target, region.base, 2));
|
||||
isc_region_consume(®ion, 2);
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ fromwire_in_nsap_ptr(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
return (dns_name_fromwire(&name, source, dctx, options, target));
|
||||
|
|
@ -91,7 +91,7 @@ towire_in_nsap_ptr(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->rdclass == dns_rdataclass_in);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(cctx, false);
|
||||
dns_name_init(&name, offsets);
|
||||
dns_rdata_toregion(rdata, ®ion);
|
||||
dns_name_fromregion(&name, ®ion);
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ fromwire_in_px(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ towire_in_px(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->rdclass == dns_rdataclass_in);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(cctx, false);
|
||||
/*
|
||||
* Preference.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ fromwire_in_srv(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ towire_in_srv(ARGS_TOWIRE) {
|
|||
REQUIRE(rdata->type == dns_rdatatype_srv);
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(cctx, false);
|
||||
/*
|
||||
* Priority, weight, port.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -756,7 +756,7 @@ generic_fromwire_in_svcb(ARGS_FROMWIRE) {
|
|||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
|
||||
|
|
@ -904,7 +904,7 @@ generic_towire_in_svcb(ARGS_TOWIRE) {
|
|||
|
||||
REQUIRE(rdata->length != 0);
|
||||
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(cctx, false);
|
||||
|
||||
/*
|
||||
* SvcPriority.
|
||||
|
|
|
|||
|
|
@ -453,7 +453,7 @@ towiresorted(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
|
|||
*/
|
||||
|
||||
rrbuffer = *target;
|
||||
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
|
||||
dns_compress_setpermitted(cctx, true);
|
||||
result = dns_name_towire2(name, cctx, target, &offset);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto rollback;
|
||||
|
|
|
|||
|
|
@ -764,7 +764,7 @@ req_render(dns_message_t *message, isc_buffer_t **bufferp, unsigned int options,
|
|||
*/
|
||||
isc_buffer_allocate(mctx, &buf1, 65535);
|
||||
|
||||
result = dns_compress_init(&cctx, -1, mctx);
|
||||
result = dns_compress_init(&cctx, mctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2530,7 +2530,7 @@ resquery_send(resquery_t *query) {
|
|||
/*
|
||||
* Convert the question to wire format.
|
||||
*/
|
||||
result = dns_compress_init(&cctx, -1, fctx->res->mctx);
|
||||
result = dns_compress_init(&cctx, fctx->res->mctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_message;
|
||||
}
|
||||
|
|
@ -2798,7 +2798,7 @@ resquery_send(resquery_t *query) {
|
|||
#ifdef HAVE_DNSTAP
|
||||
memset(&zr, 0, sizeof(zr));
|
||||
isc_buffer_init(&zb, zone, sizeof(zone));
|
||||
dns_compress_setmethods(&cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(&cctx, false);
|
||||
result = dns_name_towire(fctx->domain, &cctx, &zb);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
isc_buffer_usedregion(&zb, &zr);
|
||||
|
|
@ -9822,10 +9822,10 @@ rctx_logpacket(respctx_t *rctx) {
|
|||
* Log the response via dnstap.
|
||||
*/
|
||||
memset(&zr, 0, sizeof(zr));
|
||||
result = dns_compress_init(&cctx, -1, fctx->res->mctx);
|
||||
result = dns_compress_init(&cctx, fctx->res->mctx);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
isc_buffer_init(&zb, zone, sizeof(zone));
|
||||
dns_compress_setmethods(&cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(&cctx, false);
|
||||
result = dns_name_towire(fctx->domain, &cctx, &zb);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
isc_buffer_usedregion(&zb, &zr);
|
||||
|
|
|
|||
|
|
@ -1192,7 +1192,7 @@ render(dns_message_t *msg, isc_mem_t *mctx, isc_buffer_t *buf) {
|
|||
bool cleanup_cctx = false;
|
||||
isc_result_t result;
|
||||
|
||||
CHECK(dns_compress_init(&cctx, -1, mctx));
|
||||
CHECK(dns_compress_init(&cctx, mctx));
|
||||
cleanup_cctx = true;
|
||||
CHECK(dns_message_renderbegin(msg, &cctx, buf));
|
||||
CHECK(dns_message_rendersection(msg, DNS_SECTION_QUESTION, 0));
|
||||
|
|
|
|||
|
|
@ -537,7 +537,7 @@ ns_client_send(ns_client_t *client) {
|
|||
|
||||
client_allocsendbuf(client, &buffer, &data);
|
||||
|
||||
result = dns_compress_init(&cctx, -1, client->manager->mctx);
|
||||
result = dns_compress_init(&cctx, client->manager->mctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
|
@ -633,7 +633,7 @@ renderend:
|
|||
dns_name_t *zo = dns_zone_getorigin(client->query.authzone);
|
||||
|
||||
isc_buffer_init(&b, zone, sizeof(zone));
|
||||
dns_compress_setmethods(&cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(&cctx, false);
|
||||
eresult = dns_name_towire(zo, &cctx, &b);
|
||||
if (eresult == ISC_R_SUCCESS) {
|
||||
isc_buffer_usedregion(&b, &zr);
|
||||
|
|
|
|||
|
|
@ -1526,7 +1526,7 @@ sendstream(xfrout_ctx_t *xfr) {
|
|||
|
||||
if (is_tcp) {
|
||||
isc_region_t used;
|
||||
CHECK(dns_compress_init(&cctx, -1, xfr->mctx));
|
||||
CHECK(dns_compress_init(&cctx, xfr->mctx));
|
||||
dns_compress_setsensitive(&cctx, true);
|
||||
cleanup_cctx = true;
|
||||
CHECK(dns_message_renderbegin(msg, &cctx, &xfr->txbuf));
|
||||
|
|
|
|||
|
|
@ -171,9 +171,9 @@ ISC_RUN_TEST_IMPL(dns_dt_send) {
|
|||
|
||||
memset(&zr, 0, sizeof(zr));
|
||||
isc_buffer_init(&zb, zone, sizeof(zone));
|
||||
result = dns_compress_init(&cctx, -1, mctx);
|
||||
result = dns_compress_init(&cctx, mctx);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
dns_compress_setmethods(&cctx, DNS_COMPRESS_NONE);
|
||||
dns_compress_setpermitted(&cctx, false);
|
||||
result = dns_name_towire(zname, &cctx, &zb);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
dns_compress_invalidate(&cctx);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
@ -159,7 +158,7 @@ compress_test(dns_name_t *name1, dns_name_t *name2, dns_name_t *name3,
|
|||
|
||||
/* name compression test */
|
||||
ISC_RUN_TEST_IMPL(compression) {
|
||||
unsigned int allowed;
|
||||
bool permitted;
|
||||
dns_compress_t cctx;
|
||||
dns_decompress_t dctx;
|
||||
dns_name_t name1;
|
||||
|
|
@ -189,83 +188,52 @@ ISC_RUN_TEST_IMPL(compression) {
|
|||
r.length = sizeof(plain3);
|
||||
dns_name_fromregion(&name3, &r);
|
||||
|
||||
/* Test 1: NONE */
|
||||
allowed = DNS_COMPRESS_NONE;
|
||||
assert_int_equal(dns_compress_init(&cctx, -1, mctx), ISC_R_SUCCESS);
|
||||
dns_compress_setmethods(&cctx, allowed);
|
||||
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT);
|
||||
dns_decompress_setmethods(&dctx, allowed);
|
||||
/* Test 1: off */
|
||||
permitted = false;
|
||||
assert_int_equal(dns_compress_init(&cctx, mctx), ISC_R_SUCCESS);
|
||||
dns_compress_setpermitted(&cctx, 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);
|
||||
|
||||
/* Test2: GLOBAL14 */
|
||||
allowed = DNS_COMPRESS_GLOBAL14;
|
||||
assert_int_equal(dns_compress_init(&cctx, -1, mctx), ISC_R_SUCCESS);
|
||||
dns_compress_setmethods(&cctx, allowed);
|
||||
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT);
|
||||
dns_decompress_setmethods(&dctx, allowed);
|
||||
/* Test2: on */
|
||||
permitted = true;
|
||||
assert_int_equal(dns_compress_init(&cctx, mctx), ISC_R_SUCCESS);
|
||||
dns_compress_setpermitted(&cctx, 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);
|
||||
|
||||
/* Test3: ALL */
|
||||
allowed = DNS_COMPRESS_ALL;
|
||||
assert_int_equal(dns_compress_init(&cctx, -1, mctx), ISC_R_SUCCESS);
|
||||
dns_compress_setmethods(&cctx, allowed);
|
||||
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT);
|
||||
dns_decompress_setmethods(&dctx, allowed);
|
||||
|
||||
compress_test(&name1, &name2, &name3, plain, sizeof(plain), &cctx,
|
||||
&dctx);
|
||||
|
||||
dns_compress_rollback(&cctx, 0);
|
||||
dns_compress_invalidate(&cctx);
|
||||
|
||||
/* Test4: NONE disabled */
|
||||
allowed = DNS_COMPRESS_NONE;
|
||||
assert_int_equal(dns_compress_init(&cctx, -1, mctx), ISC_R_SUCCESS);
|
||||
dns_compress_setmethods(&cctx, allowed);
|
||||
/* Test3: off, disabled */
|
||||
permitted = false;
|
||||
assert_int_equal(dns_compress_init(&cctx, mctx), ISC_R_SUCCESS);
|
||||
dns_compress_setpermitted(&cctx, permitted);
|
||||
dns_compress_disable(&cctx);
|
||||
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT);
|
||||
dns_decompress_setmethods(&dctx, allowed);
|
||||
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);
|
||||
|
||||
/* Test5: GLOBAL14 disabled */
|
||||
allowed = DNS_COMPRESS_GLOBAL14;
|
||||
assert_int_equal(dns_compress_init(&cctx, -1, mctx), ISC_R_SUCCESS);
|
||||
dns_compress_setmethods(&cctx, allowed);
|
||||
/* Test4: on, disabled */
|
||||
permitted = true;
|
||||
assert_int_equal(dns_compress_init(&cctx, mctx), ISC_R_SUCCESS);
|
||||
dns_compress_setpermitted(&cctx, permitted);
|
||||
dns_compress_disable(&cctx);
|
||||
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT);
|
||||
dns_decompress_setmethods(&dctx, allowed);
|
||||
dctx = dns_decompress_setpermitted(DNS_DECOMPRESS_DEFAULT, permitted);
|
||||
|
||||
compress_test(&name1, &name2, &name3, plain, sizeof(plain), &cctx,
|
||||
&dctx);
|
||||
|
||||
dns_compress_rollback(&cctx, 0);
|
||||
dns_compress_invalidate(&cctx);
|
||||
|
||||
/* Test6: ALL disabled */
|
||||
allowed = DNS_COMPRESS_ALL;
|
||||
assert_int_equal(dns_compress_init(&cctx, -1, mctx), ISC_R_SUCCESS);
|
||||
dns_compress_setmethods(&cctx, allowed);
|
||||
dns_compress_disable(&cctx);
|
||||
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT);
|
||||
dns_decompress_setmethods(&dctx, allowed);
|
||||
|
||||
compress_test(&name1, &name2, &name3, plain, sizeof(plain), &cctx,
|
||||
&dctx);
|
||||
dctx);
|
||||
|
||||
dns_compress_rollback(&cctx, 0);
|
||||
dns_compress_invalidate(&cctx);
|
||||
|
|
@ -650,7 +618,7 @@ ISC_RUN_TEST_IMPL(fromwire_thread(void *arg) {
|
|||
|
||||
UNUSED(arg);
|
||||
|
||||
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT);
|
||||
dns_decompress_init(&dctx, DNS_DECOMPRESS_STRICT);
|
||||
dns_decompress_setmethods(&dctx, DNS_COMPRESS_NONE);
|
||||
|
||||
isc_buffer_init(&source, data, sizeof(data));
|
||||
|
|
|
|||
|
|
@ -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, -1, 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);
|
||||
}
|
||||
|
|
@ -176,7 +173,7 @@ rdata_towire(dns_rdata_t *rdata, unsigned char *dst, size_t dstlen,
|
|||
/*
|
||||
* Try converting input data into uncompressed wire form.
|
||||
*/
|
||||
dns_compress_init(&cctx, -1, mctx);
|
||||
dns_compress_init(&cctx, mctx);
|
||||
result = dns_rdata_towire(rdata, &cctx, &target);
|
||||
dns_compress_invalidate(&cctx);
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ add_tsig(dst_context_t *tsigctx, dns_tsigkey_t *key, isc_buffer_t *target) {
|
|||
|
||||
memset(&tsig, 0, sizeof(tsig));
|
||||
|
||||
CHECK(dns_compress_init(&cctx, -1, mctx));
|
||||
CHECK(dns_compress_init(&cctx, mctx));
|
||||
invalidate_ctx = true;
|
||||
|
||||
tsig.common.rdclass = dns_rdataclass_any;
|
||||
|
|
@ -232,7 +232,7 @@ render(isc_buffer_t *buf, unsigned flags, dns_tsigkey_t *key,
|
|||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
result = dns_compress_init(&cctx, -1, mctx);
|
||||
result = dns_compress_init(&cctx, mctx);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = dns_message_renderbegin(msg, &cctx, buf);
|
||||
|
|
|
|||
|
|
@ -336,7 +336,7 @@ attach_query_msg_to_client(ns_client_t *client, const char *qnamestr,
|
|||
/*
|
||||
* Render the query.
|
||||
*/
|
||||
dns_compress_init(&cctx, -1, mctx);
|
||||
dns_compress_init(&cctx, mctx);
|
||||
isc_buffer_init(&querybuf, query, sizeof(query));
|
||||
result = dns_message_renderbegin(message, &cctx, &querybuf);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue