[svn] commit: r2467 - in /branches/trac221b/src/bin/auth: asio_link.cc tests/asio_link_unittest.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Sat Jul 10 00:27:56 UTC 2010
Author: jinmei
Date: Sat Jul 10 00:27:56 2010
New Revision: 2467
Log:
catch invalid addresses. added tests for that.
also improved exception message on bad ports.
Modified:
branches/trac221b/src/bin/auth/asio_link.cc
branches/trac221b/src/bin/auth/tests/asio_link_unittest.cc
Modified: branches/trac221b/src/bin/auth/asio_link.cc
==============================================================================
--- branches/trac221b/src/bin/auth/asio_link.cc (original)
+++ branches/trac221b/src/bin/auth/asio_link.cc Sat Jul 10 00:27:56 2010
@@ -511,11 +511,17 @@
try {
portnum = boost::lexical_cast<uint16_t>(&port);
} catch (const boost::bad_lexical_cast& ex) {
- isc_throw(IOError, "[b10-auth] Invalid port number '" << port << "'");
+ isc_throw(IOError, "Invalid port number '" << &port << "': " <<
+ ex.what());
}
if (address != NULL) {
- asio::ip::address addr = asio::ip::address::from_string(address);
+ error_code err;
+ const ip::address addr = ip::address::from_string(address, err);
+ if (err) {
+ isc_throw(IOError, "Invalid IP address '" << address << "': "
+ << err.message());
+ }
if (addr.is_v6() && !use_ipv6) {
isc_throw(FatalError,
Modified: branches/trac221b/src/bin/auth/tests/asio_link_unittest.cc
==============================================================================
--- branches/trac221b/src/bin/auth/tests/asio_link_unittest.cc (original)
+++ branches/trac221b/src/bin/auth/tests/asio_link_unittest.cc Sat Jul 10 00:27:56 2010
@@ -96,6 +96,15 @@
EXPECT_THROW(IOService(NULL, NULL, *"domain", true, false), IOError);
}
+TEST(IOServiceTest, badAddress) {
+ EXPECT_THROW(IOService(NULL, "192.0.2.1.1", *TEST_PORT, true, false),
+ IOError);
+ EXPECT_THROW(IOService(NULL, "2001:db8:::1", *TEST_PORT, true, false),
+ IOError);
+ EXPECT_THROW(IOService(NULL, "localhost", *TEST_PORT, true, false),
+ IOError);
+}
+
struct addrinfo*
resolveAddress(const int family, const int sock_type, const int protocol) {
const char* const addr = (family == AF_INET6) ?
More information about the bind10-changes
mailing list