Parcourir la source

[2389] revised exception msg in case of unexpected nul character.

also added commments about the intent.
JINMEI Tatuya il y a 12 ans
Parent
commit
ffa3d85c7a
2 fichiers modifiés avec 9 ajouts et 3 suppressions
  1. 5 1
      src/lib/dns/rdata/in_1/a_1.cc
  2. 4 2
      src/lib/dns/rdata/in_1/aaaa_28.cc

+ 5 - 1
src/lib/dns/rdata/in_1/a_1.cc

@@ -42,8 +42,12 @@ using namespace isc::util;
 namespace {
 void
 convertToIPv4Addr(const char* src, size_t src_len, uint32_t* dst) {
+    // This check specifically rejects invalid input that begins with valid
+    // address text followed by a nul character (and possibly followed by
+    // further garbage).  It cannot be detected by inet_pton().
     if (src_len != strlen(src)) {
-        isc_throw(InvalidRdataText, "Bad IN/A RDATA text: extra character: '"
+        isc_throw(InvalidRdataText,
+                  "Bad IN/A RDATA text: unexpected nul in string: '"
                   << src << "'");
     }
     const int result = inet_pton(AF_INET, src, dst);

+ 4 - 2
src/lib/dns/rdata/in_1/aaaa_28.cc

@@ -40,9 +40,11 @@ using namespace isc::util;
 namespace {
 void
 convertToIPv6Addr(const char* src, size_t src_len, void* dst) {
+    // See a_1.cc for this check.
     if (src_len != strlen(src)) {
-        isc_throw(InvalidRdataText, "Bad IN/AAAA RDATA text: "
-                  "extra character: '" << src << "'");
+        isc_throw(InvalidRdataText,
+                  "Bad IN/AAAA RDATA text: unexpected nul in string: '"
+                  << src << "'");
     }
     const int result = inet_pton(AF_INET6, src, dst);
     if (result == 0) {