]> granicus.if.org Git - pdns/commitdiff
Do not pretty-print out-of-range RCodes
authorChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Mon, 8 Jan 2018 15:16:57 +0000 (16:16 +0100)
committerChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Mon, 8 Jan 2018 15:16:57 +0000 (16:16 +0100)
pdns/dns.cc

index 71f2c0e76d7f4def8d0c80fa5c6550e69016638d..5d40735649236b038c5c53b38812d0d94d6b5363 100644 (file)
@@ -46,7 +46,7 @@ std::vector<std::string> RCode::rcodes_s = boost::assign::list_of
   ("Err#12")
   ("Err#13")
   ("Err#14")
-  ("Err#15")
+  ("Err#15")  // Last non-extended RCode
   ("Bad OPT Version / TSIG Signature Failure")
   ("Key not recognized")
   ("Signature out of time window")
@@ -58,13 +58,15 @@ std::vector<std::string> RCode::rcodes_s = boost::assign::list_of
 ;
 
 std::string RCode::to_s(uint8_t rcode) {
-  if (rcode > RCode::rcodes_s.size()-1 ) 
-    return std::string("Err#")+std::to_string(rcode);
-  return RCode::rcodes_s[rcode];
+  if (rcode > 0xF)
+    return std::string("ErrOutOfRange");
+  return ERCode::to_s(rcode);
 }
 
 std::string ERCode::to_s(uint8_t rcode) {
-  return RCode::to_s(rcode);
+  if (rcode > RCode::rcodes_s.size()-1)
+    return std::string("Err#")+std::to_string(rcode);
+  return RCode::rcodes_s[rcode];
 }
 
 class BoundsCheckingPointer