summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMukund Sivaraman <muks@isc.org>2014-01-14 12:53:18 +0100
committerMukund Sivaraman <muks@isc.org>2014-01-14 12:53:18 +0100
commite71ef05f8698763d2e604a55aa7e39ac824241d8 (patch)
treea5747ec71c1ed57e4c25e1097e5ef3908b18447c
parent[3287] Add getter for the fingerprint (diff)
downloadkea-e71ef05f8698763d2e604a55aa7e39ac824241d8.tar.xz
kea-e71ef05f8698763d2e604a55aa7e39ac824241d8.zip
[3287] Don't passthrough BadValue exceptions in decoding hex from SSHFP
-rw-r--r--src/lib/dns/rdata/generic/sshfp_44.cc12
-rw-r--r--src/lib/dns/tests/rdata_sshfp_unittest.cc9
2 files changed, 8 insertions, 13 deletions
diff --git a/src/lib/dns/rdata/generic/sshfp_44.cc b/src/lib/dns/rdata/generic/sshfp_44.cc
index c243da7fef..346ad73f22 100644
--- a/src/lib/dns/rdata/generic/sshfp_44.cc
+++ b/src/lib/dns/rdata/generic/sshfp_44.cc
@@ -80,7 +80,11 @@ SSHFP::constructFromLexer(MasterLexer& lexer) {
// If fingerprint is missing, it's OK. See the API documentation of the
// constructor.
if (fingerprint_str.size() > 0) {
- decodeHex(fingerprint_str, fingerprint);
+ try {
+ decodeHex(fingerprint_str, fingerprint);
+ } catch (const isc::BadValue& e) {
+ isc_throw(InvalidRdataText, "Bad SSHFP fingerprint: " << e.what());
+ }
}
return (new SSHFPImpl(algorithm, fingerprint_type, fingerprint));
@@ -126,9 +130,6 @@ SSHFP::SSHFP(const string& sshfp_str) :
} catch (const MasterLexer::LexerError& ex) {
isc_throw(InvalidRdataText, "Failed to construct SSHFP from '" <<
sshfp_str << "': " << ex.what());
- } catch (const isc::BadValue& e) {
- isc_throw(InvalidRdataText,
- "Bad SSHFP fingerprint: " << e.what());
}
impl_ = impl_ptr.release();
@@ -141,8 +142,7 @@ SSHFP::SSHFP(const string& sshfp_str) :
///
/// \throw MasterLexer::LexerError General parsing error such as missing field.
/// \throw InvalidRdataText Fields are out of their valid range, or are
-/// incorrect.
-/// \throw BadValue Fingerprint is not a valid hex string.
+/// incorrect, or if the fingerprint is not a valid hex string.
///
/// \param lexer A \c MasterLexer object parsing a master file for the
/// RDATA to be created
diff --git a/src/lib/dns/tests/rdata_sshfp_unittest.cc b/src/lib/dns/tests/rdata_sshfp_unittest.cc
index b2638ef6c7..9ae23967ec 100644
--- a/src/lib/dns/tests/rdata_sshfp_unittest.cc
+++ b/src/lib/dns/tests/rdata_sshfp_unittest.cc
@@ -59,11 +59,6 @@ protected:
rdata_str, rdata_sshfp, true, true);
}
- void checkFromText_BadValue(const string& rdata_str) {
- checkFromText<generic::SSHFP, InvalidRdataText, BadValue>(
- rdata_str, rdata_sshfp, true, true);
- }
-
void checkFromText_BadString(const string& rdata_str) {
checkFromText
<generic::SSHFP, InvalidRdataText, isc::Exception>(
@@ -138,8 +133,8 @@ TEST_F(Rdata_SSHFP_Test, badText) {
checkFromText_LexerError("1");
checkFromText_LexerError("ONE 2 123456789abcdef67890123456789abcdef67890");
checkFromText_LexerError("1 TWO 123456789abcdef67890123456789abcdef67890");
- checkFromText_BadValue("1 2 BUCKLEMYSHOE");
- checkFromText_BadValue(sshfp_txt + " extra text");
+ checkFromText_InvalidText("1 2 BUCKLEMYSHOE");
+ checkFromText_InvalidText(sshfp_txt + " extra text");
// yes, these are redundant to the last test cases in algorithmTypes
checkFromText_InvalidText(