Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
BIND
Commits
051d1879
Commit
051d1879
authored
Jul 31, 2000
by
David Lawrence
Browse files
dns_name_totext() now allows names with 0 labels, which format as "@"
parent
9658892d
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/dns/include/dns/name.h
View file @
051d1879
...
...
@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: name.h,v 1.7
6
2000/07/
27 09:48:04
tale Exp $ */
/* $Id: name.h,v 1.7
7
2000/07/
31 23:09:47
tale Exp $ */
#ifndef DNS_NAME_H
#define DNS_NAME_H 1
...
...
@@ -873,8 +873,14 @@ dns_name_totext(dns_name_t *name, isc_boolean_t omit_final_dot,
/*
* Convert 'name' into text format, storing the result in 'target'.
*
* If 'omit_final_dot' is true, then the final '.' in absolute
* names other than the root name will be omitted.
* Notes:
* If 'omit_final_dot' is true, then the final '.' in absolute
* names other than the root name will be omitted.
*
* If dns_name_countlabels == 0, the name will be "@", representing the
* current origin as described by RFC 1035.
*
* The name is not NUL terminated.
*
* Requires:
*
...
...
@@ -882,8 +888,6 @@ dns_name_totext(dns_name_t *name, isc_boolean_t omit_final_dot,
*
* 'target' is a valid buffer.
*
* dns_name_countlabels(name) > 0
*
* if dns_name_isabsolute == FALSE, then omit_final_dot == FALSE
*
* Ensures:
...
...
lib/dns/name.c
View file @
051d1879
...
...
@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: name.c,v 1.9
8
2000/07/
27 09:46:16
tale Exp $ */
/* $Id: name.c,v 1.9
9
2000/07/
31 23:09:49
tale Exp $ */
#include <config.h>
...
...
@@ -1707,7 +1707,6 @@ dns_name_totext(dns_name_t *name, isc_boolean_t omit_final_dot,
* wire format.
*/
REQUIRE
(
VALID_NAME
(
name
));
REQUIRE
(
name
->
labels
>
0
);
ndata
=
name
->
ndata
;
nlen
=
name
->
length
;
...
...
@@ -1717,18 +1716,47 @@ dns_name_totext(dns_name_t *name, isc_boolean_t omit_final_dot,
trem
=
tlen
;
/* Special handling for root label. */
if
(
nlen
==
1
&&
labels
==
1
&&
*
ndata
==
0
)
{
if
(
labels
==
0
&&
nlen
==
0
)
{
/*
* Special handling for an empty name.
*/
if
(
trem
==
0
)
return
(
ISC_R_NOSPACE
);
/*
* The names of these booleans are misleading in this case.
* This empty name is not necessarily from the root node of
* the DNS root zone, nor is a final dot going to be included.
* They need to be set this way, though, to keep the "@"
* from being trounced.
*/
saw_root
=
ISC_TRUE
;
labels
=
0
;
omit_final_dot
=
ISC_FALSE
;
*
tdata
++
=
'@'
;
trem
--
;
/*
* Skip the while() loop.
*/
nlen
=
0
;
}
else
if
(
nlen
==
1
&&
labels
==
1
&&
*
ndata
==
'\0'
)
{
/*
* Special handling for the root label.
*/
if
(
trem
==
0
)
return
(
ISC_R_NOSPACE
);
saw_root
=
ISC_TRUE
;
omit_final_dot
=
ISC_FALSE
;
*
tdata
++
=
'.'
;
trem
--
;
omit_final_dot
=
ISC_FALSE
;
/*
* Skip the while() loop.
*/
nlen
=
0
;
}
while
(
labels
>
0
&&
nlen
>
0
&&
trem
>
0
)
{
labels
--
;
count
=
*
ndata
++
;
...
...
@@ -1825,7 +1853,7 @@ dns_name_totext(dns_name_t *name, isc_boolean_t omit_final_dot,
}
else
{
FATAL_ERROR
(
__FILE__
,
__LINE__
,
"Unexpected label type %02x"
,
count
);
/*
Does not return.
*/
/*
NOTREACHED
*/
}
/*
...
...
@@ -1842,7 +1870,7 @@ dns_name_totext(dns_name_t *name, isc_boolean_t omit_final_dot,
if
(
nlen
!=
0
&&
trem
==
0
)
return
(
ISC_R_NOSPACE
);
INSIST
(
nlen
==
0
);
if
(
!
saw_root
||
omit_final_dot
)
trem
++
;
...
...
@@ -3103,4 +3131,3 @@ dns_name_format(dns_name_t *name, char *cp, unsigned int size) {
}
else
snprintf
(
cp
,
size
,
"<unknown>"
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment