Commit 4a777698 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

added tests on port string validity


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac221b@2465 e5f2f494-b856-4b98-b285-d166d9295462
parent 678e8861
......@@ -510,9 +510,8 @@ IOServiceImpl::IOServiceImpl(AuthSrv* auth_server, const char* const address,
try {
portnum = boost::lexical_cast<uint16_t>(port);
} catch (const std::exception& ex) {
isc_throw(FatalError, "[b10-auth] Invalid port number '"
<< port << "'");
} catch (const boost::bad_lexical_cast& ex) {
isc_throw(IOError, "[b10-auth] Invalid port number '" << port << "'");
}
if (address != NULL) {
......
......@@ -390,7 +390,7 @@ public:
/// \brief The constructor. Currently very specific to the authoritative
/// server implementation.
IOService(AuthSrv* auth_server, const char* const address,
const char* port, bool use_ipv4, bool use_ipv6);
const char* const port, bool use_ipv4, bool use_ipv6);
/// \brief The destructor.
~IOService();
//@}
......
......@@ -89,6 +89,13 @@ TEST(IOSocketTest, dummySockets) {
EXPECT_EQ(-1, IOSocket::getDummyTCPSocket().getNative());
}
TEST(IOServiceTest, badPort) {
EXPECT_THROW(IOService(NULL, NULL, "65536", true, false), IOError);
EXPECT_THROW(IOService(NULL, NULL, "5300.0", true, false), IOError);
EXPECT_THROW(IOService(NULL, NULL, "-1", true, false), IOError);
EXPECT_THROW(IOService(NULL, NULL, "domain", true, false), IOError);
}
struct addrinfo*
resolveAddress(const int family, const int sock_type, const int protocol) {
const char* const addr = (family == AF_INET6) ?
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment