2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 05:57:52 +00:00

* local label offset 255 is reserved.

* don't add domainnames with local compression pointers as
	  valid global compression targets unless edns is high enough.
This commit is contained in:
Mark Andrews 1999-03-11 00:26:21 +00:00
parent 044903fc42
commit de10b83a23
3 changed files with 20 additions and 14 deletions

View File

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: compress.c,v 1.6 1999/03/06 04:08:29 halley Exp $ */
/* $Id: compress.c,v 1.7 1999/03/11 00:26:20 marka Exp $ */
#include <config.h>
@ -124,7 +124,7 @@ dns_compress_localinit(dns_compress_t *cctx, dns_name_t *owner,
labels --;
wl++;
ll++;
if (ll > 255)
if (ll > 254)
return (DNS_R_SUCCESS);
dns_name_getlabel(&name, 0, &label);
if (dns_label_type(&label) != dns_labeltype_bitstring)
@ -159,7 +159,7 @@ dns_compress_localinit(dns_compress_t *cctx, dns_name_t *owner,
return (DNS_R_SUCCESS);
}
ll++;
if (ll > 255)
if (ll > 254)
return (DNS_R_SUCCESS);
} while (bits > 1);
}
@ -242,19 +242,21 @@ dns_compress_findlocal(dns_compress_t *cctx, dns_name_t *name,
void
dns_compress_add(dns_compress_t *cctx, dns_name_t *prefix,
dns_name_t *suffix, isc_uint16_t offset)
dns_name_t *suffix, isc_uint16_t offset,
isc_boolean_t local)
{
isc_uint16_t local;
isc_uint16_t localoffset;
REQUIRE(VALID_CCTX(cctx));
if (cctx->local != NULL && (cctx->allowed & DNS_COMPRESS_LOCAL) != 0) {
REQUIRE(cctx->rdata <= offset);
local = offset - cctx->rdata + 256;
compress_add(cctx->local, prefix, suffix, local, ISC_TRUE,
localoffset = offset - cctx->rdata + 256;
compress_add(cctx->local, prefix, suffix, localoffset, ISC_TRUE,
cctx->mctx);
}
compress_add(cctx->global, prefix, suffix, offset, cctx->global16,
cctx->mctx);
if ((cctx->edns > -1) || !local)
compress_add(cctx->global, prefix, suffix, offset,
cctx->global16, cctx->mctx);
}
void

View File

@ -208,10 +208,14 @@ dns_compress_findlocal(dns_compress_t *cctx, dns_name_t *name,
void
dns_compress_add(dns_compress_t *cctx, dns_name_t *prefix,
dns_name_t *suffix, isc_uint16_t offset);
dns_name_t *suffix, isc_uint16_t offset,
isc_boolean_t local);
/*
* Add compression pointers for labels in prefix to RBT's.
* If 'prefix' is absolute 'suffix' must be NULL.
* If 'prefix' is absolute 'suffix' must be NULL otherwise
* suffix must be absolute.
* 'local' indicates that the domain name at offset contains
* a local compression pointer.
*
* Requires:
* 'cctx' initalised

View File

@ -2057,7 +2057,7 @@ dns_name_towire(dns_name_t *name, dns_compress_t *cctx,
isc_buffer_putuint16(target, go);
}
if (gp.length != 0)
dns_compress_add(cctx, &gp, &gs, offset);
dns_compress_add(cctx, &gp, &gs, offset, ISC_FALSE);
} else if (lf) {
if (target->length - target->used < lp.length)
return (DNS_R_NOSPACE);
@ -2078,14 +2078,14 @@ dns_name_towire(dns_name_t *name, dns_compress_t *cctx,
isc_buffer_putuint16(target, lo);
}
if (lp.length != 0)
dns_compress_add(cctx, &lp, &ls, offset);
dns_compress_add(cctx, &lp, &ls, offset, ISC_TRUE);
} else {
if (target->length - target->used < name->length)
return (DNS_R_NOSPACE);
(void)memcpy((unsigned char *)target->base + target->used,
name->ndata, (size_t)name->length);
isc_buffer_add(target, name->length);
dns_compress_add(cctx, name, NULL, offset);
dns_compress_add(cctx, name, NULL, offset, ISC_FALSE);
}
return (DNS_R_SUCCESS);
}