]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1583] not directly related, intermediate update: reject null RRset in
authorJINMEI Tatuya <jinmei@isc.org>
Tue, 14 Feb 2012 01:13:23 +0000 (17:13 -0800)
committerJINMEI Tatuya <jinmei@isc.org>
Tue, 14 Feb 2012 01:13:23 +0000 (17:13 -0800)
Message::addRRset().

src/lib/dns/message.cc
src/lib/dns/message.h
src/lib/dns/tests/message_unittest.cc

index b3e9229ae88904edd0500dcb83e7184f3c53990f..0db68c619865aed8ed58a09dddd8635d8cb72081 100644 (file)
@@ -489,6 +489,10 @@ Message::getRRCount(const Section section) const {
 
 void
 Message::addRRset(const Section section, RRsetPtr rrset, const bool sign) {
+    if (!rrset) {
+        isc_throw(InvalidParameter,
+                  "NULL RRset is given to Message::addRRset");
+    }
     if (impl_->mode_ != Message::RENDER) {
         isc_throw(InvalidMessageOperation,
                   "addRRset performed in non-render mode");
index 47632cb3e4a2034cc0f152f8f674459495c5661e..33551c099e8681f52f170348f079aa6bc03db241 100644 (file)
@@ -462,15 +462,19 @@ public:
     /// This interface takes into account the RRSIG possibly attached to
     /// \c rrset.  This interface design needs to be revisited later.
     ///
-    /// This method is only allowed in the \c RENDER mode;
-    /// if the \c Message is in other mode, an exception of class
-    /// InvalidMessageOperation will be thrown.
-    /// \c section must be a valid constant of the \c Section type;
-    /// otherwise, an exception of class \c OutOfRange will be thrown.
-    ///
     /// Note that \c addRRset() does not currently check for duplicate
     /// data before inserting RRsets.  The caller is responsible for
     /// checking for these (see \c hasRRset() below).
+    ///
+    /// \throw InvalidParameter rrset is NULL
+    /// \throw InvalidMessageOperation The message is not in the \c RENDER
+    /// mode.
+    /// \throw OutOfRange \c section doesn't specify a valid \c Section value.
+    ///
+    /// \param section The message section to which the rrset is to be added
+    /// \param rrset The rrset to be added.  Must not be NULL.
+    /// \param sign If true, and if \c rrset has associated RRSIGs, the
+    /// RRSIGs will also be added to the same section of the message.
     void addRRset(const Section section, RRsetPtr rrset, bool sign = false);
 
     /// \brief Determine whether the given section already has an RRset
index c4d4984da8d70a9121bd316dd2268ef68f63b20a..c5bc7fd840d0ec65e5d254e569cbae2a4d212d48 100644 (file)
@@ -324,6 +324,10 @@ TEST_F(MessageTest, badAddRRset) {
                                         rrset_a), InvalidMessageOperation);
     // out-of-band section ID
     EXPECT_THROW(message_render.addRRset(bogus_section, rrset_a), OutOfRange);
+
+    // NULL RRset
+    EXPECT_THROW(message_render.addRRset(Message::SECTION_ANSWER, RRsetPtr()),
+                 InvalidParameter);
 }
 
 TEST_F(MessageTest, hasRRset) {