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