[svn] commit: r1806 - in /trunk/src/lib/dns: ./ name.cc rdata/generic/rrsig_46.cc tests/ tests/name_unittest.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Tue May 11 00:16:44 UTC 2010


Author: jinmei
Date: Tue May 11 00:16:43 2010
New Revision: 1806

Log:
merged branches/177 (trac #177).
(with the usual prop change to rrsig_46.cc)

Modified:
    trunk/src/lib/dns/   (props changed)
    trunk/src/lib/dns/name.cc
    trunk/src/lib/dns/rdata/generic/rrsig_46.cc   (props changed)
    trunk/src/lib/dns/tests/   (props changed)
    trunk/src/lib/dns/tests/name_unittest.cc

Modified: trunk/src/lib/dns/name.cc
==============================================================================
--- trunk/src/lib/dns/name.cc (original)
+++ trunk/src/lib/dns/name.cc Tue May 11 00:16:43 2010
@@ -667,7 +667,7 @@
 
 Name
 Name::split(unsigned int first, unsigned int n) const {
-    if (n == 0 || first + n > labelcount_) {
+    if (n == 0 || n > labelcount_ || first > labelcount_ - n) {
         isc_throw(OutOfRange, "Name::split: invalid split range");
     }
 

Modified: trunk/src/lib/dns/tests/name_unittest.cc
==============================================================================
--- trunk/src/lib/dns/tests/name_unittest.cc (original)
+++ trunk/src/lib/dns/tests/name_unittest.cc Tue May 11 00:16:43 2010
@@ -18,6 +18,7 @@
 #include <string>
 #include <sstream>
 #include <iomanip>
+#include <limits>
 #include <stdexcept>
 
 #include <dns/buffer.h>
@@ -492,6 +493,11 @@
     // invalid range: an exception should be thrown.
     EXPECT_THROW(example_name.split(1, 0), OutOfRange);
     EXPECT_THROW(example_name.split(2, 3), OutOfRange);
+
+    // invalid range: the following parameters would cause overflow,
+    // bypassing naive validation.
+    EXPECT_THROW(example_name.split(1, numeric_limits<unsigned int>::max()),
+                 OutOfRange);
 }
 
 TEST_F(NameTest, downcase) {




More information about the bind10-changes mailing list