]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1839] Fix toWire() for class=ANY and class=NONE cases
authorMukund Sivaraman <muks@isc.org>
Thu, 9 Jan 2014 03:57:53 +0000 (09:27 +0530)
committerMukund Sivaraman <muks@isc.org>
Thu, 9 Jan 2014 03:57:53 +0000 (09:27 +0530)
src/lib/dns/rrset.cc

index 839c7b7d5445f3b8d9a8e6d25d13e62bcdb365e4..7f4f42f7e29fd99434c7e2d6e00dd339cca2e943 100644 (file)
@@ -186,12 +186,26 @@ public:
 // rrsetToWire() above to avoid duplication.
 unsigned int
 BasicRRsetImpl::toWire(AbstractMessageRenderer& renderer, size_t limit) const {
-    unsigned int n = 0;
-
     if (rdatalist_.empty()) {
-        isc_throw(EmptyRRset, "toWire() is attempted for an empty RRset");
+        // empty rrsets are only allowed for classes ANY and NONE
+        if (rrclass_ != RRClass::ANY() &&
+            rrclass_ != RRClass::NONE()) {
+            isc_throw(EmptyRRset, "toWire() is attempted for an empty RRset");
+        }
+
+        // For an empty RRset, write the name, type, class and TTL once,
+        // followed by empty rdata.
+        name_.toWire(renderer);
+        rrtype_.toWire(renderer);
+        rrclass_.toWire(renderer);
+        ttl_.toWire(renderer);
+        renderer.writeUint16(0);
+        // Still counts as 1 'rr'; it does show up in the message
+        return (1);
     }
 
+    unsigned int n = 0;
+
     // sort the set of Rdata based on rrset-order and sortlist, and possible
     // other options.  Details to be considered.
     BOOST_FOREACH(const ConstRdataPtr& rdata, rdatalist_) {