From 9192e92f7d0f4e78385a1d5f9b6607cc5bf0e42a Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Wed, 6 Jan 1999 20:04:41 +0000 Subject: [PATCH] check if compression type is allowed --- lib/dns/name.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/lib/dns/name.c b/lib/dns/name.c index 831999d309..aa49f3e3d7 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -28,6 +28,7 @@ #include #include #include +#include #define NAME_MAGIC 0x444E536EU /* DNSn. */ #define VALID_NAME(n) ((n) != NULL && \ @@ -1366,7 +1367,7 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, REQUIRE(name != NULL); REQUIRE(isc_buffer_type(source) == ISC_BUFFERTYPE_BINARY); REQUIRE(isc_buffer_type(target) == ISC_BUFFERTYPE_BINARY); - /* XXX REQUIRE(dctx != NULL); */ + REQUIRE(dctx != NULL); /* * Invalidate 'name'. @@ -1422,8 +1423,12 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, n = c; state = fw_ordinary; } else if (c >= 192) { - /* XXX check if allowed. */ - /* Ordinary 14-bit pointer. */ + /* + * Ordinary 14-bit pointer. + */ + if ((dctx->allowed & DNS_COMPRESS_GLOBAL14) == + 0) + return (DNS_R_DISALLOWED); new_current = c & 0x3F; n = 1; state = fw_newcurrent; @@ -1436,13 +1441,24 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, saw_bitstring = ISC_TRUE; state = fw_bitstring; } else if (c == DNS_LABELTYPE_GLOBALCOMP16) { - /* XXX check if allowed. */ - /* 16-bit pointer. */ + /* + * 16-bit pointer. + */ + if ((dctx->allowed & DNS_COMPRESS_GLOBAL16) == + 0) + return (DNS_R_DISALLOWED); new_current = 0; n = 2; state = fw_newcurrent; } else if (c == DNS_LABELTYPE_LOCALCOMP) { - /* XXX check if allowed. */ + /* + * Local compression. + */ + if ((dctx->allowed & DNS_COMPRESS_GLOBAL16) == + 0) + return (DNS_R_DISALLOWED); + + /* XXX */ return (DNS_R_NOTIMPLEMENTED); } else return (DNS_R_BADLABELTYPE);