BIND 10 trac2384, updated. 4d514f5b0ec7b9eff71c067604bb41ad5c850221 [2384] Little bit more range checking

BIND 10 source code commits bind10-changes at lists.isc.org
Sat Nov 10 10:45:28 UTC 2012


The branch, trac2384 has been updated
       via  4d514f5b0ec7b9eff71c067604bb41ad5c850221 (commit)
      from  09e72e680a11354f6215946b1981b006a1f3f192 (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 4d514f5b0ec7b9eff71c067604bb41ad5c850221
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Sat Nov 10 11:28:53 2012 +0100

    [2384] Little bit more range checking
    
    There was a gap when one thing could overflow to negative numbers.

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

Summary of changes:
 src/lib/dns/rrttl.cc                |    3 ++-
 src/lib/dns/tests/rrttl_unittest.cc |    8 ++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/rrttl.cc b/src/lib/dns/rrttl.cc
index 5f7dae5..620cf7c 100644
--- a/src/lib/dns/rrttl.cc
+++ b/src/lib/dns/rrttl.cc
@@ -116,7 +116,8 @@ RRTTL::RRTTL(const std::string& ttlstr) {
             // Check the partial value is still in range (the value can only
             // grow, so if we get out of range now, it won't get better, so
             // there's no need to continue).
-            if (value < 0 || val < 0 || val > 0xffffffff) {
+            if (value < 0 || value > 0xffffffff || val < 0 ||
+                val > 0xffffffff) {
                 isc_throw(InvalidRRTTL, "Part of TTL out of range: " <<
                           ttlstr);
             }
diff --git a/src/lib/dns/tests/rrttl_unittest.cc b/src/lib/dns/tests/rrttl_unittest.cc
index 61e7849..754dd6c 100644
--- a/src/lib/dns/tests/rrttl_unittest.cc
+++ b/src/lib/dns/tests/rrttl_unittest.cc
@@ -131,11 +131,11 @@ TEST_F(RRTTLTest, fromTextUnit) {
     EXPECT_THROW(RRTTL("9223372036854775807S9223372036854775807S2S"),
                  InvalidRRTTL);
     // Second part out of range, but it immediately wraps (2S+2^64-2S)
-    EXPECT_THROW(RRTTL("2S18446744073709551614S"),
-                 InvalidRRTTL);
+    EXPECT_THROW(RRTTL("2S18446744073709551614S"), InvalidRRTTL);
     // The whole thing wraps right away (2^64S)
-    EXPECT_THROW(RRTTL("18446744073709551616S"),
-                 InvalidRRTTL);
+    EXPECT_THROW(RRTTL("18446744073709551616S"), InvalidRRTTL);
+    // Second part out of range, and will become negative with the unit,
+    EXPECT_THROW(RRTTL("256S307445734561825856M"), InvalidRRTTL);
 
     // Missing before unit.
     EXPECT_THROW(RRTTL("W5H"), InvalidRRTTL);



More information about the bind10-changes mailing list