Commit 0e2ef3c7 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[2470] check and reject ampty add-RRset callback.

parent 822fa315
......@@ -12,6 +12,8 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include <exceptions/exceptions.h>
#include <dns/name.h>
#include <dns/rdataclass.h>
#include <dns/rrcollator.h>
......@@ -34,7 +36,11 @@ public:
Impl(const AddRRsetCallback& callback,
const MasterLoaderCallbacks& issue_callback) :
callback_(callback), issue_callback_(issue_callback)
{}
{
if (!callback_) {
isc_throw(InvalidParameter, "Empty add RRset callback");
}
}
void addRR(const Name& name, const RRClass& rrclass,
const RRType& rrtype, const RRTTL& rrttl,
......
......@@ -63,6 +63,8 @@ public:
/// \brief Constructor.
///
/// \c callback must not be an empty functor.
///
/// If the optional issue_callback parameter is given, it will be used
/// to report any errors and non fatal warnings found in the collator's
/// operation. By default special callbacks that do nothing are used.
......@@ -74,6 +76,7 @@ public:
/// "<unknown source>" for the source name and the line number of 0 via
/// the callback.
///
/// \throw isc::InvalidParameter Empty RRset callback is given.
/// \throw std::bad_alloc Internal memory allocation fails. This should
/// be very rare.
///
......
......@@ -237,6 +237,11 @@ TEST_F(RRCollatorTest, throwFromCallback) {
checkRRset(origin_, rrclass_, RRType::A(), rrttl_, rdatas_);
}
TEST_F(RRCollatorTest, emptyCallback) {
const AddRRsetCallback empty_callback;
EXPECT_THROW(RRCollator collator(empty_callback), isc::InvalidParameter);
}
TEST_F(RRCollatorTest, withMasterLoader) {
// Test a simple case with MasterLoader. There shouldn't be anything
// special, but that's the mainly intended usage of the collator, so we
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment