BIND 10 master, updated. 83e33ec80c0c6485d8b116b13045b3488071770f Merge branch 'trac838'
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Jun 7 08:29:24 UTC 2011
The branch, master has been updated
via 83e33ec80c0c6485d8b116b13045b3488071770f (commit)
via e4543dee376bae0e459f9008a2061f2a2529dcee (commit)
via c4412dfaa0bb8c6e95cb4476e80b648cfa9288f2 (commit)
via d098ac2ee97872ebcd8366cb700d7d2a5e668b8c (commit)
via 9c4b079aca67cffe9385e54671f8eb9ed232e1e5 (commit)
via b1b486e59d86633e7b5e17aeedf0f78688ecef05 (commit)
via 45fb91884dc0741384a14e7f52633b0566779dff (commit)
via c166c0c96a476eea511fe363b90df3d78fae7506 (commit)
via 0e1eaada6f38f23e7de9404a94b2cd5dd2794879 (commit)
via 16f90854f8957d12e2861bc77303f186402a8805 (commit)
from acf47441057d4ce66bcb84b67038e1e99e822c72 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 83e33ec80c0c6485d8b116b13045b3488071770f
Merge: acf47441057d4ce66bcb84b67038e1e99e822c72 e4543dee376bae0e459f9008a2061f2a2529dcee
Author: Ocean Wang <wanghaidong at cnnic.cn>
Date: Tue Jun 7 16:24:01 2011 +0800
Merge branch 'trac838'
-----------------------------------------------------------------------
Summary of changes:
src/lib/util/encode/base_n.cc | 35 ++++++++++++++++++++++++-----
src/lib/util/tests/base32hex_unittest.cc | 7 +++++-
src/lib/util/tests/base64_unittest.cc | 8 ++++++-
3 files changed, 42 insertions(+), 8 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/util/encode/base_n.cc b/src/lib/util/encode/base_n.cc
index 406dc77..0026a0b 100644
--- a/src/lib/util/encode/base_n.cc
+++ b/src/lib/util/encode/base_n.cc
@@ -160,19 +160,42 @@ public:
base_zero_code_(base_zero_code),
base_(base), base_beginpad_(base_beginpad), base_end_(base_end),
in_pad_(false)
- {}
+ {
+ // Skip beginning spaces, if any. We need do it here because
+ // otherwise the first call to operator*() would be confused.
+ skipSpaces();
+ }
DecodeNormalizer& operator++() {
++base_;
- while (base_ != base_end_ && isspace(*base_)) {
- ++base_;
- }
+ skipSpaces();
if (base_ == base_beginpad_) {
in_pad_ = true;
}
return (*this);
}
+ void skipSpaces() {
+ // If (char is signed and) *base_ < 0, on Windows platform with Visual
+ // Studio compiler it may trigger _ASSERTE((unsigned)(c + 1) <= 256);
+ // so make sure that the parameter of isspace() is larger than 0.
+ // We don't simply cast it to unsigned char to avoid confusing the
+ // isspace() implementation with a possible extension for values
+ // larger than 127. Also note the check is not ">= 0"; for systems
+ // where char is unsigned that would always be true and would possibly
+ // trigger a compiler warning that could stop the build.
+ while (base_ != base_end_ && *base_ > 0 && isspace(*base_)) {
+ ++base_;
+ }
+ }
const char& operator*() const {
- if (in_pad_ && *base_ == BASE_PADDING_CHAR) {
+ if (base_ == base_end_) {
+ // binary_from_baseX calls this operator when it needs more bits
+ // even if the internal iterator (base_) has reached its end
+ // (if that happens it means the input is an incomplete baseX
+ // string and should be rejected). So this is the only point
+ // we can catch and reject this type of invalid input.
+ isc_throw(BadValue, "Unexpected end of input in BASE decoder");
+ }
+ if (in_pad_) {
return (base_zero_code_);
} else {
return (*base_);
@@ -268,7 +291,7 @@ BaseNTransformer<BitsPerChunk, BaseZeroCode, Encoder, Decoder>::decode(
isc_throw(BadValue, "Too many " << algorithm
<< " padding characters: " << input);
}
- } else if (!isspace(ch)) {
+ } else if (ch < 0 || !isspace(ch)) {
break;
}
++srit;
diff --git a/src/lib/util/tests/base32hex_unittest.cc b/src/lib/util/tests/base32hex_unittest.cc
index bf79627..fa4a290 100644
--- a/src/lib/util/tests/base32hex_unittest.cc
+++ b/src/lib/util/tests/base32hex_unittest.cc
@@ -66,7 +66,7 @@ decodeCheck(const string& input_string, vector<uint8_t>& output,
const string& expected)
{
decodeBase32Hex(input_string, output);
- EXPECT_EQ(expected, string(&output[0], &output[0] + output.size()));
+ EXPECT_EQ(expected, string(output.begin(), output.end()));
}
TEST_F(Base32HexTest, decode) {
@@ -79,6 +79,11 @@ TEST_F(Base32HexTest, decode) {
// whitespace should be allowed
decodeCheck("CP NM\tUOG=", decoded_data, "foob");
decodeCheck("CPNMU===\n", decoded_data, "foo");
+ decodeCheck(" CP NM\tUOG=", decoded_data, "foob");
+ decodeCheck(" ", decoded_data, "");
+
+ // Incomplete input
+ EXPECT_THROW(decodeBase32Hex("CPNMUOJ", decoded_data), BadValue);
// invalid number of padding characters
EXPECT_THROW(decodeBase32Hex("CPNMU0==", decoded_data), BadValue);
diff --git a/src/lib/util/tests/base64_unittest.cc b/src/lib/util/tests/base64_unittest.cc
index c2b2785..b0c926d 100644
--- a/src/lib/util/tests/base64_unittest.cc
+++ b/src/lib/util/tests/base64_unittest.cc
@@ -52,7 +52,7 @@ decodeCheck(const string& input_string, vector<uint8_t>& output,
const string& expected)
{
decodeBase64(input_string, output);
- EXPECT_EQ(expected, string(&output[0], &output[0] + output.size()));
+ EXPECT_EQ(expected, string(output.begin(), output.end()));
}
TEST_F(Base64Test, decode) {
@@ -66,6 +66,12 @@ TEST_F(Base64Test, decode) {
decodeCheck("Zm 9v\tYmF\ny", decoded_data, "foobar");
decodeCheck("Zm9vYg==", decoded_data, "foob");
decodeCheck("Zm9vYmE=\n", decoded_data, "fooba");
+ decodeCheck(" Zm9vYmE=\n", decoded_data, "fooba");
+ decodeCheck(" ", decoded_data, "");
+ decodeCheck("\n\t", decoded_data, "");
+
+ // incomplete input
+ EXPECT_THROW(decodeBase64("Zm9vYmF", decoded_data), BadValue);
// only up to 2 padding characters are allowed
EXPECT_THROW(decodeBase64("A===", decoded_data), BadValue);
More information about the bind10-changes
mailing list