mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-10-11 13:56:46 +00:00
[1177] Don't propagate name exceptions from findPreviousName
They should be turned into DataSourceError instead, as they mean bad data in the DB.
This commit is contained in:
@@ -614,8 +614,22 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
|
||||
|
||||
Name
|
||||
DatabaseClient::Finder::findPreviousName(const Name& name) const {
|
||||
return (Name(accessor_->findPreviousName(zone_id_,
|
||||
name.reverse().toText())));
|
||||
const string str(accessor_->findPreviousName(zone_id_,
|
||||
name.reverse().toText()));
|
||||
try {
|
||||
return (Name(str));
|
||||
}
|
||||
/*
|
||||
* To avoid having the same code many times, we just catch all the
|
||||
* exceptions and handle them in a common code below
|
||||
*/
|
||||
catch (const isc::dns::EmptyLabel&) {}
|
||||
catch (const isc::dns::TooLongLabel&) {}
|
||||
catch (const isc::dns::BadLabelType&) {}
|
||||
catch (const isc::dns::BadEscape&) {}
|
||||
catch (const isc::dns::TooLongName&) {}
|
||||
catch (const isc::dns::IncompleteName&) {}
|
||||
isc_throw(DataSourceError, "Bad name " + str + " from findPreviousName");
|
||||
}
|
||||
|
||||
Name
|
||||
|
@@ -566,6 +566,8 @@ public:
|
||||
return ("www.example.org.");
|
||||
} else if (rname == "org.example.badnsec2.") {
|
||||
return ("badnsec1.example.org.");
|
||||
} else if (rname == "org.example.brokenname.") {
|
||||
return ("brokenname...example.org.");
|
||||
} else if (rname == "org.example.notimplnsec." ||
|
||||
rname == "org.example.wild.here.") {
|
||||
isc_throw(isc::NotImplemented, "Not implemented in this test");
|
||||
@@ -2347,4 +2349,11 @@ TEST_F(MockDatabaseClientTest, missingNSEC) {
|
||||
DataSourceError);
|
||||
}
|
||||
|
||||
TEST_F(MockDatabaseClientTest, badName) {
|
||||
shared_ptr<DatabaseClient::Finder> finder(this->getFinder());
|
||||
|
||||
EXPECT_THROW(finder->findPreviousName(Name("brokenname.example.org.")),
|
||||
DataSourceError);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user