mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
dns_name_fromwire() should have been using up to the end of the
active region, not the end of the remaining region. bin/named/wire_debug.c bin/tests/wire_test.c adjusted for above change. dns_name_fromwire() was not computing nrem and nused correctly for bitstream labels.
This commit is contained in:
parent
7c0539bea5
commit
b5819ca3eb
4 changed files with 25 additions and 13 deletions
|
|
@ -124,6 +124,7 @@ resolve_packet(dns_db_t *db, isc_buffer_t *source, isc_buffer_t *target)
|
|||
dns_dbnode_t *node;
|
||||
dns_rdataset_t rdataset;
|
||||
isc_boolean_t authoritative = ISC_TRUE;
|
||||
isc_region_t r;
|
||||
|
||||
count = 0;
|
||||
status = 0;
|
||||
|
|
@ -151,6 +152,8 @@ resolve_packet(dns_db_t *db, isc_buffer_t *source, isc_buffer_t *target)
|
|||
*/
|
||||
isc_buffer_init(&tbuf, t, sizeof(t), ISC_BUFFERTYPE_BINARY);
|
||||
dns_name_init(&name, NULL);
|
||||
isc_buffer_remaining(source, &r);
|
||||
isc_buffer_setactive(source, r.length);
|
||||
result = dns_name_fromwire(&name, source, &dctx, ISC_FALSE, &tbuf);
|
||||
qtype = getshort(source);
|
||||
qclass = getshort(source);
|
||||
|
|
|
|||
|
|
@ -157,6 +157,7 @@ getquestions(isc_buffer_t *source, dns_namelist_t *section, unsigned int count,
|
|||
unsigned int type, class;
|
||||
dns_name_t *name, *curr;
|
||||
dns_rdatalist_t *rdatalist;
|
||||
isc_region_t r;
|
||||
|
||||
ISC_LIST_INIT(*section);
|
||||
while (count > 0) {
|
||||
|
|
@ -167,6 +168,9 @@ getquestions(isc_buffer_t *source, dns_namelist_t *section, unsigned int count,
|
|||
exit(1);
|
||||
}
|
||||
name = &names[ncount++];
|
||||
|
||||
isc_buffer_remaining(source, &r);
|
||||
isc_buffer_setactive(source, r.length);
|
||||
(void)getname(name, source, target);
|
||||
for (curr = ISC_LIST_HEAD(*section);
|
||||
curr != NULL;
|
||||
|
|
@ -224,6 +228,8 @@ getsection(isc_buffer_t *source, dns_namelist_t *section, unsigned int count,
|
|||
exit(1);
|
||||
}
|
||||
name = &names[ncount++];
|
||||
isc_buffer_remaining(source, &r);
|
||||
isc_buffer_setactive(source, r.length);
|
||||
(void)getname(name, source, target);
|
||||
for (curr = ISC_LIST_HEAD(*section);
|
||||
curr != NULL;
|
||||
|
|
|
|||
|
|
@ -289,7 +289,8 @@ dns_name_compare(dns_name_t *name1, dns_name_t *name2);
|
|||
int
|
||||
dns_name_rdatacompare(dns_name_t *name1, dns_name_t *name2);
|
||||
/*
|
||||
* Compare two names as if they are part of rdata.
|
||||
* Compare two names as if they are part of rdata in DNSSEC cononical
|
||||
* form.
|
||||
*
|
||||
* Requires:
|
||||
* 'name1' is a valid absolute name
|
||||
|
|
@ -430,7 +431,8 @@ dns_result_t dns_name_fromwire(dns_name_t *name,
|
|||
isc_boolean_t downcase,
|
||||
isc_buffer_t *target);
|
||||
/*
|
||||
* Copy the possibly-compressed name at source into target, decompressing it.
|
||||
* Copy the possibly-compressed name at source (active region) into target,
|
||||
* decompressing it.
|
||||
*
|
||||
* Notes:
|
||||
* Decompression policy is controlled by 'dctx'.
|
||||
|
|
@ -451,8 +453,8 @@ dns_result_t dns_name_fromwire(dns_name_t *name,
|
|||
* 'name' is a valid name.
|
||||
*
|
||||
* 'source' is a valid buffer of type ISC_BUFFERTYPE_BINARY, and the
|
||||
* first byte of the used region should be the first byte of a DNS wire
|
||||
* format message.
|
||||
* first byte of the active region should be the first byte of a DNS
|
||||
* wire * format message.
|
||||
*
|
||||
* 'target' is a valid buffer of type ISC_BUFFERTYPE_BINARY.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1668,7 +1668,7 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source,
|
|||
* rather for correctness. Speed will be addressed in the future.
|
||||
*/
|
||||
|
||||
while (current < source->used && !done) {
|
||||
while (current < source->active && !done) {
|
||||
c = *cdata++;
|
||||
current++;
|
||||
if (hops == 0)
|
||||
|
|
@ -1740,16 +1740,17 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source,
|
|||
state = fw_start;
|
||||
break;
|
||||
case fw_bitstring:
|
||||
if (nrem < c + 1)
|
||||
return (DNS_R_NOSPACE);
|
||||
nrem -= c + 1;
|
||||
nused += c + 1;
|
||||
*ndata++ = c;
|
||||
if (c == 0)
|
||||
c = 256;
|
||||
n = c / 8;
|
||||
if (c % 8 != 0)
|
||||
n = 256 / 8;
|
||||
else
|
||||
n = c / 8;
|
||||
if ((c % 8) != 0)
|
||||
n++;
|
||||
if (nrem < n + 1)
|
||||
return (DNS_R_NOSPACE);
|
||||
nrem -= n + 1;
|
||||
nused += n + 1;
|
||||
*ndata++ = c;
|
||||
state = fw_copy;
|
||||
break;
|
||||
case fw_newcurrent:
|
||||
|
|
|
|||
Loading…
Reference in a new issue