mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 14:35:29 +00:00
[2497] Return NULL upon exception in rdata::createRdata()
This commit is contained in:
@@ -87,9 +87,17 @@ createRdata(const RRType& rrtype, const RRClass& rrclass,
|
|||||||
MasterLoader::Options options,
|
MasterLoader::Options options,
|
||||||
MasterLoaderCallbacks& callbacks)
|
MasterLoaderCallbacks& callbacks)
|
||||||
{
|
{
|
||||||
return (RRParamRegistry::getRegistry().createRdata(rrtype, rrclass,
|
RdataPtr ret;
|
||||||
|
|
||||||
|
try {
|
||||||
|
ret = RRParamRegistry::getRegistry().createRdata(rrtype, rrclass,
|
||||||
lexer, origin,
|
lexer, origin,
|
||||||
options, callbacks));
|
options, callbacks);
|
||||||
|
} catch (...) {
|
||||||
|
// ret is NULL here.
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@@ -119,11 +119,9 @@ TEST_F(Rdata_AFSDB_Test, createFromLexer) {
|
|||||||
*test::createRdataUsingLexer(RRType::AFSDB(), RRClass::IN(),
|
*test::createRdataUsingLexer(RRType::AFSDB(), RRClass::IN(),
|
||||||
afsdb_text)));
|
afsdb_text)));
|
||||||
|
|
||||||
// Check that bad input throws as usual
|
// Exceptions cause NULL to be returned.
|
||||||
EXPECT_THROW({
|
EXPECT_FALSE(test::createRdataUsingLexer(RRType::AFSDB(), RRClass::IN(),
|
||||||
*test::createRdataUsingLexer(RRType::AFSDB(), RRClass::IN(),
|
"1root.example.com."));
|
||||||
"1root.example.com.");
|
|
||||||
}, InvalidRdataText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Rdata_AFSDB_Test, toWireBuffer) {
|
TEST_F(Rdata_AFSDB_Test, toWireBuffer) {
|
||||||
|
@@ -68,10 +68,9 @@ TEST_F(Rdata_DHCID_Test, createFromLexer) {
|
|||||||
*test::createRdataUsingLexer(RRType::DHCID(), RRClass::IN(),
|
*test::createRdataUsingLexer(RRType::DHCID(), RRClass::IN(),
|
||||||
string_dhcid)));
|
string_dhcid)));
|
||||||
|
|
||||||
// Check that bad input throws as usual
|
// Exceptions cause NULL to be returned.
|
||||||
EXPECT_THROW({
|
EXPECT_FALSE(test::createRdataUsingLexer(RRType::DHCID(), RRClass::IN(),
|
||||||
*test::createRdataUsingLexer(RRType::DHCID(), RRClass::IN(), "00");
|
"00"));
|
||||||
}, isc::BadValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Rdata_DHCID_Test, toWireRenderer) {
|
TEST_F(Rdata_DHCID_Test, toWireRenderer) {
|
||||||
|
@@ -88,11 +88,9 @@ TEST_F(Rdata_DNSKEY_Test, createFromLexer) {
|
|||||||
*test::createRdataUsingLexer(RRType::DNSKEY(), RRClass::IN(),
|
*test::createRdataUsingLexer(RRType::DNSKEY(), RRClass::IN(),
|
||||||
dnskey_txt)));
|
dnskey_txt)));
|
||||||
|
|
||||||
// Check that bad input throws as usual
|
// Exceptions cause NULL to be returned.
|
||||||
EXPECT_THROW({
|
EXPECT_FALSE(test::createRdataUsingLexer(RRType::DNSKEY(), RRClass::IN(),
|
||||||
*test::createRdataUsingLexer(RRType::DNSKEY(), RRClass::IN(),
|
"257 3 5"));
|
||||||
"257 3 5");
|
|
||||||
}, InvalidRdataText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Rdata_DNSKEY_Test, toWireRenderer) {
|
TEST_F(Rdata_DNSKEY_Test, toWireRenderer) {
|
||||||
|
@@ -90,11 +90,9 @@ TYPED_TEST(Rdata_DS_LIKE_Test, createFromLexer_DS_LIKE) {
|
|||||||
*test::createRdataUsingLexer(RRTYPE<TypeParam>(), RRClass::IN(),
|
*test::createRdataUsingLexer(RRTYPE<TypeParam>(), RRClass::IN(),
|
||||||
ds_like_txt)));
|
ds_like_txt)));
|
||||||
|
|
||||||
// Check that bad input throws as usual
|
// Exceptions cause NULL to be returned.
|
||||||
EXPECT_THROW({
|
EXPECT_FALSE(test::createRdataUsingLexer(RRTYPE<TypeParam>(), RRClass::IN(),
|
||||||
*test::createRdataUsingLexer(RRTYPE<TypeParam>(), RRClass::IN(),
|
"99999 5 2 BEEF"));
|
||||||
"99999 5 2 BEEF");
|
|
||||||
}, InvalidRdataText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TYPED_TEST(Rdata_DS_LIKE_Test, assignment_DS_LIKE) {
|
TYPED_TEST(Rdata_DS_LIKE_Test, assignment_DS_LIKE) {
|
||||||
|
@@ -83,11 +83,9 @@ TEST_F(Rdata_HINFO_Test, createFromLexer) {
|
|||||||
*test::createRdataUsingLexer(RRType::HINFO(), RRClass::IN(),
|
*test::createRdataUsingLexer(RRType::HINFO(), RRClass::IN(),
|
||||||
hinfo_str)));
|
hinfo_str)));
|
||||||
|
|
||||||
// Check that bad input throws as usual
|
// Exceptions cause NULL to be returned.
|
||||||
EXPECT_THROW({
|
EXPECT_FALSE(test::createRdataUsingLexer(RRType::HINFO(), RRClass::IN(),
|
||||||
*test::createRdataUsingLexer(RRType::HINFO(), RRClass::IN(),
|
"\"Pentium\"\"Linux\""));
|
||||||
"\"Pentium\"\"Linux\"");
|
|
||||||
}, InvalidRdataText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Rdata_HINFO_Test, toText) {
|
TEST_F(Rdata_HINFO_Test, toText) {
|
||||||
|
@@ -67,10 +67,9 @@ TEST_F(Rdata_MX_Test, createFromLexer) {
|
|||||||
*test::createRdataUsingLexer(RRType::MX(), RRClass::IN(),
|
*test::createRdataUsingLexer(RRType::MX(), RRClass::IN(),
|
||||||
"10 mx.example.com")));
|
"10 mx.example.com")));
|
||||||
|
|
||||||
EXPECT_THROW({
|
// Exceptions cause NULL to be returned.
|
||||||
test::createRdataUsingLexer(RRType::MX(), RRClass::IN(),
|
EXPECT_FALSE(test::createRdataUsingLexer(RRType::MX(), RRClass::IN(),
|
||||||
"10 mx. example.com");
|
"10 mx. example.com"));
|
||||||
}, InvalidRdataText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Rdata_MX_Test, toWireRenderer) {
|
TEST_F(Rdata_MX_Test, toWireRenderer) {
|
||||||
|
@@ -135,12 +135,10 @@ TEST_F(Rdata_NAPTR_Test, createFromLexer) {
|
|||||||
*test::createRdataUsingLexer(RRType::NAPTR(), RRClass::IN(),
|
*test::createRdataUsingLexer(RRType::NAPTR(), RRClass::IN(),
|
||||||
naptr_str)));
|
naptr_str)));
|
||||||
|
|
||||||
// Check that bad input throws as usual (order > 65535)
|
// Exceptions cause NULL to be returned.
|
||||||
EXPECT_THROW({
|
EXPECT_FALSE(test::createRdataUsingLexer(RRType::NAPTR(), RRClass::IN(),
|
||||||
*test::createRdataUsingLexer(RRType::NAPTR(), RRClass::IN(),
|
|
||||||
"65536 10 S SIP \"\" "
|
"65536 10 S SIP \"\" "
|
||||||
"_sip._udp.example.com.");
|
"_sip._udp.example.com."));
|
||||||
}, InvalidRdataText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Rdata_NAPTR_Test, toWire) {
|
TEST_F(Rdata_NAPTR_Test, toWire) {
|
||||||
|
@@ -91,10 +91,9 @@ TEST_F(Rdata_NS_Test, createFromLexer) {
|
|||||||
*test::createRdataUsingLexer(RRType::NS(), RRClass::IN(),
|
*test::createRdataUsingLexer(RRType::NS(), RRClass::IN(),
|
||||||
"ns.example.com")));
|
"ns.example.com")));
|
||||||
|
|
||||||
EXPECT_THROW({
|
// Exceptions cause NULL to be returned.
|
||||||
test::createRdataUsingLexer(RRType::NS(), RRClass::IN(),
|
EXPECT_FALSE(test::createRdataUsingLexer(RRType::NS(), RRClass::IN(),
|
||||||
"");
|
""));
|
||||||
}, IncompleteName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Rdata_NS_Test, toWireBuffer) {
|
TEST_F(Rdata_NS_Test, toWireBuffer) {
|
||||||
|
@@ -136,12 +136,10 @@ TEST_F(Rdata_NSEC3_Test, createFromLexer) {
|
|||||||
*test::createRdataUsingLexer(RRType::NSEC3(), RRClass::IN(),
|
*test::createRdataUsingLexer(RRType::NSEC3(), RRClass::IN(),
|
||||||
nsec3_txt)));
|
nsec3_txt)));
|
||||||
|
|
||||||
// Check that bad input throws as usual (next hash shouldn't be
|
// Exceptions cause NULL to be returned.
|
||||||
// padded)
|
EXPECT_FALSE(test::createRdataUsingLexer(RRType::NSEC3(), RRClass::IN(),
|
||||||
EXPECT_THROW({
|
"1 1 1 ADDAFEEE CPNMU=== "
|
||||||
*test::createRdataUsingLexer(RRType::NSEC3(), RRClass::IN(),
|
"A NS SOA"));
|
||||||
"1 1 1 ADDAFEEE CPNMU=== A NS SOA");
|
|
||||||
}, InvalidRdataText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Rdata_NSEC3_Test, assign) {
|
TEST_F(Rdata_NSEC3_Test, assign) {
|
||||||
|
@@ -213,12 +213,10 @@ TYPED_TEST(NSEC3PARAMLikeTest, createFromLexer) {
|
|||||||
*test::createRdataUsingLexer(this->getType(), RRClass::IN(),
|
*test::createRdataUsingLexer(this->getType(), RRClass::IN(),
|
||||||
this->salt_txt)));
|
this->salt_txt)));
|
||||||
|
|
||||||
// Check that bad input throws as usual (too large algorithm)
|
// Exceptions cause NULL to be returned.
|
||||||
EXPECT_THROW({
|
EXPECT_FALSE(test::createRdataUsingLexer(this->getType(), RRClass::IN(),
|
||||||
*test::createRdataUsingLexer(this->getType(), RRClass::IN(),
|
|
||||||
"1000000 1 1 ADDAFEEE" +
|
"1000000 1 1 ADDAFEEE" +
|
||||||
this->getCommonText());
|
this->getCommonText()));
|
||||||
}, InvalidRdataText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename OUTPUT_TYPE>
|
template <typename OUTPUT_TYPE>
|
||||||
|
@@ -72,11 +72,9 @@ TEST_F(Rdata_NSEC_Test, createFromLexer_NSEC) {
|
|||||||
*test::createRdataUsingLexer(RRType::NSEC(), RRClass::IN(),
|
*test::createRdataUsingLexer(RRType::NSEC(), RRClass::IN(),
|
||||||
nsec_txt)));
|
nsec_txt)));
|
||||||
|
|
||||||
// Check that bad input throws as usual
|
// Exceptions cause NULL to be returned.
|
||||||
EXPECT_THROW({
|
EXPECT_FALSE(test::createRdataUsingLexer(RRType::NSEC(), RRClass::IN(),
|
||||||
*test::createRdataUsingLexer(RRType::NSEC(), RRClass::IN(),
|
"www.isc.org."));
|
||||||
"www.isc.org.");
|
|
||||||
}, InvalidRdataText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Rdata_NSEC_Test, toWireRenderer_NSEC) {
|
TEST_F(Rdata_NSEC_Test, toWireRenderer_NSEC) {
|
||||||
|
@@ -57,11 +57,10 @@ TEST_F(Rdata_OPT_Test, createFromWire) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Rdata_OPT_Test, createFromLexer) {
|
TEST_F(Rdata_OPT_Test, createFromLexer) {
|
||||||
// OPT RR cannot be created from text.
|
// OPT RR cannot be created from text. Exceptions cause NULL to be
|
||||||
EXPECT_THROW({
|
// returned.
|
||||||
*test::createRdataUsingLexer(RRType::OPT(), RRClass::IN(),
|
EXPECT_FALSE(test::createRdataUsingLexer(RRType::OPT(), RRClass::IN(),
|
||||||
"this does not matter");
|
"this does not matter"));
|
||||||
}, InvalidRdataText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Rdata_OPT_Test, toWireBuffer) {
|
TEST_F(Rdata_OPT_Test, toWireBuffer) {
|
||||||
|
@@ -112,11 +112,9 @@ TEST_F(Rdata_RP_Test, createFromLexer) {
|
|||||||
"root.example.com. "
|
"root.example.com. "
|
||||||
"rp-text.example.com.")));
|
"rp-text.example.com.")));
|
||||||
|
|
||||||
// Check that bad input throws as usual
|
// Exceptions cause NULL to be returned.
|
||||||
EXPECT_THROW({
|
EXPECT_FALSE(test::createRdataUsingLexer(RRType::RP(), RRClass::IN(),
|
||||||
*test::createRdataUsingLexer(RRType::RP(), RRClass::IN(),
|
"mailbox.example.com."));
|
||||||
"mailbox.example.com.");
|
|
||||||
}, InvalidRdataText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Rdata_RP_Test, toWireBuffer) {
|
TEST_F(Rdata_RP_Test, toWireBuffer) {
|
||||||
|
@@ -106,11 +106,9 @@ TEST_F(Rdata_RRSIG_Test, createFromLexer) {
|
|||||||
*test::createRdataUsingLexer(RRType::RRSIG(), RRClass::IN(),
|
*test::createRdataUsingLexer(RRType::RRSIG(), RRClass::IN(),
|
||||||
rrsig_txt)));
|
rrsig_txt)));
|
||||||
|
|
||||||
// Check that bad input throws as usual
|
// Exceptions cause NULL to be returned.
|
||||||
EXPECT_THROW({
|
EXPECT_FALSE(test::createRdataUsingLexer(RRType::RRSIG(), RRClass::IN(),
|
||||||
*test::createRdataUsingLexer(RRType::RRSIG(), RRClass::IN(),
|
"INVALIDINPUT"));
|
||||||
"INVALIDINPUT");
|
|
||||||
}, InvalidRdataText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Rdata_RRSIG_Test, toWireRenderer) {
|
TEST_F(Rdata_RRSIG_Test, toWireRenderer) {
|
||||||
|
@@ -123,11 +123,11 @@ TEST_F(Rdata_SRV_Test, createFromLexer) {
|
|||||||
EXPECT_EQ(0, rdata_srv.compare(
|
EXPECT_EQ(0, rdata_srv.compare(
|
||||||
*test::createRdataUsingLexer(RRType::SRV(), RRClass::IN(),
|
*test::createRdataUsingLexer(RRType::SRV(), RRClass::IN(),
|
||||||
"1 5 1500 a.example.com.")));
|
"1 5 1500 a.example.com.")));
|
||||||
// port is too large
|
|
||||||
EXPECT_THROW({
|
// Exceptions cause NULL to be returned.
|
||||||
*test::createRdataUsingLexer(RRType::SRV(), RRClass::IN(),
|
EXPECT_FALSE(test::createRdataUsingLexer(RRType::SRV(), RRClass::IN(),
|
||||||
"1 5 281474976710656 a.example.com.");
|
"1 5 281474976710656 "
|
||||||
}, InvalidRdataText);
|
"a.example.com."));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Rdata_SRV_Test, toWireBuffer) {
|
TEST_F(Rdata_SRV_Test, toWireBuffer) {
|
||||||
|
@@ -252,11 +252,9 @@ TEST_F(Rdata_TSIG_Test, createFromLexer) {
|
|||||||
*test::createRdataUsingLexer(RRType::TSIG(), RRClass::ANY(),
|
*test::createRdataUsingLexer(RRType::TSIG(), RRClass::ANY(),
|
||||||
valid_text1)));
|
valid_text1)));
|
||||||
|
|
||||||
// Check that bad input throws as usual
|
// Exceptions cause NULL to be returned.
|
||||||
EXPECT_THROW({
|
EXPECT_FALSE(test::createRdataUsingLexer(RRType::TSIG(), RRClass::ANY(),
|
||||||
*test::createRdataUsingLexer(RRType::TSIG(), RRClass::ANY(),
|
"foo 0 0 0 0 BADKEY 0 0"));
|
||||||
"foo 0 0 0 0 BADKEY 0 0");
|
|
||||||
}, InvalidRdataText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Rdata_TSIG_Test, assignment) {
|
TEST_F(Rdata_TSIG_Test, assignment) {
|
||||||
|
Reference in New Issue
Block a user