Browse Source

[1638] in parseNSEC3ParamText(), checked the encoded salt length first to
reject too large salt sooner.

JINMEI Tatuya 13 years ago
parent
commit
d3877a1903
1 changed files with 7 additions and 4 deletions
  1. 7 4
      src/lib/dns/rdata/generic/detail/nsec3param_common.cc

+ 7 - 4
src/lib/dns/rdata/generic/detail/nsec3param_common.cc

@@ -74,13 +74,16 @@ parseNSEC3ParamText(const char* const rrtype_name,
             iterations);
     }
 
+    // Salt is up to 255 bytes, and space is not allowed in the HEX encoding,
+    // so the encoded string cannot be longer than the double of max length
+    // of the actual salt.
+    if (salthex.size() > 255 * 2) {
+        isc_throw(InvalidRdataText, rrtype_name << " salt is too long: "
+                  << salthex.size() << " (encoded) bytes");
+    }
     if (salthex != "-") {       // "-" means a 0-length salt
         decodeHex(salthex, salt);
     }
-    if (salt.size() > 255) {
-        isc_throw(InvalidRdataText, rrtype_name << " salt is too long: "
-                  << salt.size() << " bytes");
-    }
 
     return (ParseNSEC3ParamResult(hashalg, flags, iterations));
 }