mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 05:57:52 +00:00
Shrink decompression contexts
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.
This commit is contained in:
parent
129a522d88
commit
1d807d84f1
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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 |
|
||||
|---------|-----------------------|
|
||||
|
@ -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);
|
||||
|
||||
/*
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -72,16 +72,11 @@ struct dns_compress {
|
||||
isc_mem_t *mctx; /*%< Memory context. */
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
DNS_DECOMPRESS_ANY, /*%< Any compression */
|
||||
DNS_DECOMPRESS_STRICT, /*%< Allowed compression */
|
||||
DNS_DECOMPRESS_NONE /*%< No compression */
|
||||
} dns_decompresstype_t;
|
||||
|
||||
struct dns_decompress {
|
||||
unsigned int magic; /*%< Magic number. */
|
||||
dns_decompresstype_t type; /*%< Strict checking */
|
||||
bool permitted;
|
||||
enum dns_decompress {
|
||||
DNS_DECOMPRESS_DEFAULT,
|
||||
DNS_DECOMPRESS_PERMITTED,
|
||||
DNS_DECOMPRESS_NEVER,
|
||||
DNS_DECOMPRESS_ALWAYS,
|
||||
};
|
||||
|
||||
isc_result_t
|
||||
@ -204,7 +199,6 @@ dns_compress_add(dns_compress_t *cctx, const dns_name_t *name,
|
||||
|
||||
void
|
||||
dns_compress_rollback(dns_compress_t *cctx, uint16_t offset);
|
||||
|
||||
/*%<
|
||||
* Remove any compression pointers from global table >= offset.
|
||||
*
|
||||
@ -212,45 +206,27 @@ dns_compress_rollback(dns_compress_t *cctx, uint16_t offset);
|
||||
*\li 'cctx' is initialized.
|
||||
*/
|
||||
|
||||
void
|
||||
dns_decompress_init(dns_decompress_t *dctx, dns_decompresstype_t type);
|
||||
|
||||
/*%<
|
||||
* Initializes 'dctx'.
|
||||
* Records 'edns' and 'type' into the structure.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'dctx' to be a valid pointer.
|
||||
/*%
|
||||
* Set whether decompression is allowed, according to RFC 3597
|
||||
*/
|
||||
static inline dns_decompress_t /* inline to suppress code generation */
|
||||
dns_decompress_setpermitted(dns_decompress_t dctx, bool permitted) {
|
||||
if (dctx == DNS_DECOMPRESS_NEVER || dctx == DNS_DECOMPRESS_ALWAYS) {
|
||||
return (dctx);
|
||||
} else if (permitted) {
|
||||
return (DNS_DECOMPRESS_PERMITTED);
|
||||
} else {
|
||||
return (DNS_DECOMPRESS_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
dns_decompress_invalidate(dns_decompress_t *dctx);
|
||||
|
||||
/*%<
|
||||
* Invalidates 'dctx'.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'dctx' to be initialized
|
||||
*/
|
||||
|
||||
void
|
||||
dns_decompress_setpermitted(dns_decompress_t *dctx, bool permitted);
|
||||
|
||||
/*%<
|
||||
* Sets whether decompression is allowed, according to RFC 3597
|
||||
*
|
||||
* Requires:
|
||||
*\li 'dctx' to be initialized
|
||||
*/
|
||||
|
||||
bool
|
||||
dns_decompress_getpermitted(dns_decompress_t *dctx);
|
||||
|
||||
/*%<
|
||||
/*%
|
||||
* Returns whether decompression is allowed here
|
||||
*
|
||||
* Requires:
|
||||
*\li 'dctx' to be initialized
|
||||
*/
|
||||
static inline bool /* inline to suppress code generation */
|
||||
dns_decompress_getpermitted(dns_decompress_t dctx) {
|
||||
return (dctx == DNS_DECOMPRESS_ALWAYS ||
|
||||
dctx == DNS_DECOMPRESS_PERMITTED);
|
||||
}
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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, 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, 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,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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -192,7 +192,7 @@ fromwire_amtrelay(ARGS_FROMWIRE) {
|
||||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setpermitted(dctx, false);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
isc_buffer_activeregion(source, ®ion);
|
||||
if (region.length < 2) {
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
/*
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
/*
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -253,7 +253,7 @@ fromwire_tkey(ARGS_FROMWIRE) {
|
||||
UNUSED(type);
|
||||
UNUSED(rdclass);
|
||||
|
||||
dns_decompress_setpermitted(dctx, false);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
/*
|
||||
* Algorithm.
|
||||
|
@ -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);
|
||||
/*
|
||||
|
@ -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_setpermitted(dctx, false);
|
||||
dctx = dns_decompress_setpermitted(dctx, false);
|
||||
|
||||
dns_name_init(&name, NULL);
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user