BIND 10 master, updated. 96b66c0c79dccf9a0206a45916b9b23fe9b94f74 [master] Merge branch 'trac2784' correct perfdhcp crash on mismatched command line parameters.

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Apr 10 12:04:12 UTC 2013


The branch, master has been updated
       via  96b66c0c79dccf9a0206a45916b9b23fe9b94f74 (commit)
       via  7a7dc17a59cb4d66ec4f7f4cf96afa81284b3040 (commit)
       via  30fc969527cf3ae250cc6d2ee0ec0248c4b943d0 (commit)
       via  c7d8adb3fb0903c2b3a8627de14e85742f338d83 (commit)
       via  2f3d1fe8c582c75c98b739e0f7b1486b0a9141ca (commit)
      from  937635d75665f331226774ca1b7c5bff791b9d69 (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 96b66c0c79dccf9a0206a45916b9b23fe9b94f74
Merge: 937635d 7a7dc17
Author: Thomas Markwalder <tmark at isc.org>
Date:   Wed Apr 10 08:03:33 2013 -0400

    [master] Merge branch 'trac2784' correct perfdhcp crash on mismatched
    command line parameters.

-----------------------------------------------------------------------

Summary of changes:
 tests/tools/perfdhcp/test_control.cc               |   18 +++++++++++++-----
 .../tools/perfdhcp/tests/test_control_unittest.cc  |   12 ++++++++++++
 2 files changed, 25 insertions(+), 5 deletions(-)

-----------------------------------------------------------------------
diff --git a/tests/tools/perfdhcp/test_control.cc b/tests/tools/perfdhcp/test_control.cc
index 0cd69b4..425d978 100644
--- a/tests/tools/perfdhcp/test_control.cc
+++ b/tests/tools/perfdhcp/test_control.cc
@@ -592,19 +592,27 @@ TestControl::openSocket() const {
     std::string localname = options.getLocalName();
     std::string servername = options.getServerName();
     uint16_t port = options.getLocalPort();
-    uint8_t family = AF_INET;
     int sock = 0;
+
+    uint8_t family = (options.getIpVersion() == 6) ? AF_INET6 : AF_INET; 
     IOAddress remoteaddr(servername);
+    
+    // Check for mismatch between IP option and server address
+    if (family != remoteaddr.getFamily()) {
+        isc_throw(InvalidParameter, 
+                  "Values for IP version: " <<  
+                  static_cast<unsigned int>(options.getIpVersion()) <<
+                  " and server address: " << servername << " are mismatched."); 
+    }
+
     if (port == 0) {
-        if (options.getIpVersion() == 6) {
+        if (family == AF_INET6) {
             port = DHCP6_CLIENT_PORT;
         } else if (options.getIpVersion() == 4) {
             port = 67; //  TODO: find out why port 68 is wrong here.
         }
     }
-    if (options.getIpVersion() == 6) {
-        family = AF_INET6;
-    }
+
     // Local name is specified along with '-l' option.
     // It may point to interface name or local address.
     if (!localname.empty()) {
diff --git a/tests/tools/perfdhcp/tests/test_control_unittest.cc b/tests/tools/perfdhcp/tests/test_control_unittest.cc
index f7666ae..3e0145c 100644
--- a/tests/tools/perfdhcp/tests/test_control_unittest.cc
+++ b/tests/tools/perfdhcp/tests/test_control_unittest.cc
@@ -672,6 +672,18 @@ TEST_F(TestControlTest, GenerateDuid) {
     testDuid();
 }
 
+TEST_F(TestControlTest, MisMatchVerionServer) {
+    NakedTestControl tc;
+
+    // make sure we catch -6 paired with v4 address
+    ASSERT_NO_THROW(processCmdLine("perfdhcp -l 127.0.0.1 -6 192.168.1.1"));
+    EXPECT_THROW(tc.openSocket(), isc::InvalidParameter);
+
+    // make sure we catch -4 paired with v6 address
+    ASSERT_NO_THROW(processCmdLine("perfdhcp -l 127.0.0.1 -4 ff02::1:2"));
+    EXPECT_THROW(tc.openSocket(), isc::InvalidParameter);
+}
+
 TEST_F(TestControlTest, GenerateMacAddress) {
     // Simulate one client only. Always the same MAC address will be
     // generated.



More information about the bind10-changes mailing list