summaryrefslogtreecommitdiffstats
path: root/lib/dns/name.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dns/name.c')
-rw-r--r--lib/dns/name.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/lib/dns/name.c b/lib/dns/name.c
index f4ea3e9..80864b8 100644
--- a/lib/dns/name.c
+++ b/lib/dns/name.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2008, 2010 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1998-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: name.c,v 1.165 2008/04/01 23:47:10 tbox Exp $ */
+/* $Id: name.c,v 1.165.120.3 2010-07-09 05:15:05 each Exp $ */
/*! \file */
@@ -901,7 +901,7 @@ dns_name_getlabelsequence(const dns_name_t *source,
REQUIRE(VALID_NAME(source));
REQUIRE(VALID_NAME(target));
REQUIRE(first <= source->labels);
- REQUIRE(first + n <= source->labels);
+ REQUIRE(n <= source->labels - first); /* note first+n could overflow */
REQUIRE(BINDABLE(target));
SETUP_OFFSETS(source, offsets, odata);
@@ -1324,6 +1324,21 @@ isc_result_t
dns_name_totext(dns_name_t *name, isc_boolean_t omit_final_dot,
isc_buffer_t *target)
{
+ unsigned int options = DNS_NAME_MASTERFILE;
+
+ if (omit_final_dot)
+ options |= DNS_NAME_OMITFINALDOT;
+ return (dns_name_totext2(name, options, target));
+}
+
+isc_result_t
+dns_name_toprincipal(dns_name_t *name, isc_buffer_t *target) {
+ return (dns_name_totext2(name, DNS_NAME_OMITFINALDOT, target));
+}
+
+isc_result_t
+dns_name_totext2(dns_name_t *name, unsigned int options, isc_buffer_t *target)
+{
unsigned char *ndata;
char *tdata;
unsigned int nlen, tlen;
@@ -1337,6 +1352,8 @@ dns_name_totext(dns_name_t *name, isc_boolean_t omit_final_dot,
dns_name_totextfilter_t totext_filter_proc = NULL;
isc_result_t result;
#endif
+ isc_boolean_t omit_final_dot =
+ ISC_TF(options & DNS_NAME_OMITFINALDOT);
/*
* This function assumes the name is in proper uncompressed
@@ -1412,15 +1429,17 @@ dns_name_totext(dns_name_t *name, isc_boolean_t omit_final_dot,
while (count > 0) {
c = *ndata;
switch (c) {
+ /* Special modifiers in zone files. */
+ case 0x40: /* '@' */
+ case 0x24: /* '$' */
+ if ((options & DNS_NAME_MASTERFILE) == 0)
+ goto no_escape;
case 0x22: /* '"' */
case 0x28: /* '(' */
case 0x29: /* ')' */
case 0x2E: /* '.' */
case 0x3B: /* ';' */
case 0x5C: /* '\\' */
- /* Special modifiers in zone files. */
- case 0x40: /* '@' */
- case 0x24: /* '$' */
if (trem < 2)
return (ISC_R_NOSPACE);
*tdata++ = '\\';
@@ -1430,6 +1449,7 @@ dns_name_totext(dns_name_t *name, isc_boolean_t omit_final_dot,
trem -= 2;
nlen--;
break;
+ no_escape:
default:
if (c > 0x20 && c < 0x7f) {
if (trem == 0)
OpenPOWER on IntegriCloud