Commit 63c345f5 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[2124] Catch isc::BadValue and throw InvalidRdataText instead

parent 2d714adf
......@@ -85,7 +85,12 @@ SSHFP::SSHFP(const std::string& sshfp_str) {
algorithm_ = algorithm;
fingerprint_type_ = fingerprint_type;
decodeHex(fingerprintbuf.str(), fingerprint_);
try {
decodeHex(fingerprintbuf.str(), fingerprint_);
} catch (const isc::BadValue& e) {
isc_throw(InvalidRdataText, "Bad SSHFP fingerprint: " << e.what());
}
}
SSHFP::SSHFP(uint8_t algorithm, uint8_t fingerprint_type,
......@@ -101,7 +106,12 @@ SSHFP::SSHFP(uint8_t algorithm, uint8_t fingerprint_type,
algorithm_ = algorithm;
fingerprint_type_ = fingerprint_type;
decodeHex(fingerprint, fingerprint_);
try {
decodeHex(fingerprint, fingerprint_);
} catch (const isc::BadValue& e) {
isc_throw(InvalidRdataText, "Bad SSHFP fingerprint: " << e.what());
}
}
SSHFP::SSHFP(const SSHFP& other) :
......
......@@ -82,7 +82,7 @@ TEST_F(Rdata_SSHFP_Test, badText) {
EXPECT_THROW(const generic::SSHFP rdata_sshfp("1"), InvalidRdataText);
EXPECT_THROW(const generic::SSHFP rdata_sshfp("1 2"), InvalidRdataText);
EXPECT_THROW(const generic::SSHFP rdata_sshfp("BUCKLE MY SHOES"), InvalidRdataText);
EXPECT_THROW(const generic::SSHFP rdata_sshfp("1 2 foo bar"), isc::BadValue);
EXPECT_THROW(const generic::SSHFP rdata_sshfp("1 2 foo bar"), InvalidRdataText);
}
TEST_F(Rdata_SSHFP_Test, copy) {
......
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