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
Kea
Commits
398b2215
Commit
398b2215
authored
Jul 05, 2012
by
JINMEI Tatuya
Committed by
Mukund Sivaraman
Jul 05, 2012
Browse files
[2053] Use getDataLength() to find out the right end to stop
parent
23ae3c2b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/dns/labelsequence.cc
View file @
398b2215
...
...
@@ -116,23 +116,18 @@ std::string
LabelSequence
::
toText
(
bool
omit_final_dot
)
const
{
Name
::
NameString
::
const_iterator
np
=
name_
.
ndata_
.
begin
()
+
name_
.
offsets_
[
first_label_
];
const
Name
::
NameString
::
const_iterator
np_end
=
n
ame_
.
ndata_
.
end
();
const
Name
::
NameString
::
const_iterator
np_end
=
n
p
+
getDataLength
();
// use for integrity check
unsigned
int
labels
=
last_label_
-
first_label_
;
// init with an impossible value to catch error cases in the end:
unsigned
int
count
=
Name
::
MAX_LABELLEN
+
1
;
// result string: it will roughly have the same length as the wire format
//
nam
e data. reserve that length to minimize reallocation.
//
label sequenc
e data. reserve that length to minimize reallocation.
std
::
string
result
;
result
.
reserve
(
name_
.
get
Length
());
result
.
reserve
(
getData
Length
());
while
(
np
!=
np_end
)
{
if
(
labels
==
0
)
{
count
=
0
;
break
;
}
labels
--
;
count
=
*
np
++
;
...
...
@@ -187,8 +182,9 @@ LabelSequence::toText(bool omit_final_dot) const {
}
}
// We should be at the end of the data and have consumed all labels.
assert
(
np
==
np_end
);
assert
(
labels
==
0
);
assert
(
count
==
0
);
return
(
result
);
}
...
...
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