Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
50d012ed
Commit
50d012ed
authored
Jul 19, 2012
by
Mukund Sivaraman
Browse files
[2124] Relax algorithm and fingerprint type checks for SSHFP
parent
412e1fc0
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/dns/rdata/generic/sshfp_44.cc
View file @
50d012ed
...
...
@@ -61,12 +61,6 @@ SSHFP::SSHFP(const std::string& sshfp_str)
if
(
iss
.
bad
()
||
iss
.
fail
())
{
isc_throw
(
InvalidRdataText
,
"Invalid SSHFP text"
);
}
if
((
algorithm
<
1
)
||
(
algorithm
>
2
))
{
isc_throw
(
InvalidRdataText
,
"SSHFP algorithm number out of range"
);
}
if
(
fingerprint_type
!=
1
)
{
isc_throw
(
InvalidRdataText
,
"SSHFP fingerprint type out of range"
);
}
iss
.
read
(
&
peekc
,
1
);
if
(
!
iss
.
good
()
||
!
isspace
(
peekc
,
iss
.
getloc
()))
{
...
...
@@ -82,13 +76,6 @@ SSHFP::SSHFP(const std::string& sshfp_str)
SSHFP
::
SSHFP
(
uint8_t
algorithm
,
uint8_t
fingerprint_type
,
const
std
::
string
&
fingerprint
)
{
if
((
algorithm
<
1
)
||
(
algorithm
>
2
))
{
isc_throw
(
InvalidRdataText
,
"SSHFP algorithm number out of range"
);
}
if
(
fingerprint_type
!=
1
)
{
isc_throw
(
InvalidRdataText
,
"SSHFP fingerprint type out of range"
);
}
algorithm_
=
algorithm
;
fingerprint_type_
=
fingerprint_type
;
decodeHex
(
fingerprint
,
fingerprint_
);
...
...
src/lib/dns/tests/rdata_sshfp_unittest.cc
View file @
50d012ed
...
...
@@ -56,11 +56,28 @@ TEST_F(Rdata_SSHFP_Test, createFromText) {
EXPECT_EQ
(
0
,
rdata_sshfp4
.
compare
(
rdata_sshfp
));
}
TEST_F
(
Rdata_SSHFP_Test
,
algorithmTypes
)
{
// Some of these may not be RFC conformant, but we relax the check
// in our code to work with algorithm and fingerprint types that may
// show up in the future.
EXPECT_NO_THROW
(
const
generic
::
SSHFP
rdata_sshfp
(
"0 1 123456789abcdef67890123456789abcdef67890"
));
EXPECT_NO_THROW
(
const
generic
::
SSHFP
rdata_sshfp
(
"1 1 123456789abcdef67890123456789abcdef67890"
));
EXPECT_NO_THROW
(
const
generic
::
SSHFP
rdata_sshfp
(
"2 1 123456789abcdef67890123456789abcdef67890"
));
EXPECT_NO_THROW
(
const
generic
::
SSHFP
rdata_sshfp
(
"3 1 123456789abcdef67890123456789abcdef67890"
));
EXPECT_NO_THROW
(
const
generic
::
SSHFP
rdata_sshfp
(
"128 1 123456789abcdef67890123456789abcdef67890"
));
EXPECT_NO_THROW
(
const
generic
::
SSHFP
rdata_sshfp
(
"255 1 123456789abcdef67890123456789abcdef67890"
));
EXPECT_NO_THROW
(
const
generic
::
SSHFP
rdata_sshfp
(
"1 1 123456789abcdef67890123456789abcdef67890"
));
EXPECT_NO_THROW
(
const
generic
::
SSHFP
rdata_sshfp
(
"1 2 123456789abcdef67890123456789abcdef67890"
));
EXPECT_NO_THROW
(
const
generic
::
SSHFP
rdata_sshfp
(
"1 3 123456789abcdef67890123456789abcdef67890"
));
EXPECT_NO_THROW
(
const
generic
::
SSHFP
rdata_sshfp
(
"1 128 123456789abcdef67890123456789abcdef67890"
));
EXPECT_NO_THROW
(
const
generic
::
SSHFP
rdata_sshfp
(
"1 255 123456789abcdef67890123456789abcdef67890"
));
}
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"
),
InvalidRdataText
);
EXPECT_THROW
(
const
generic
::
SSHFP
rdata_sshfp
(
"1 2 foo bar"
),
isc
::
BadValue
);
}
TEST_F
(
Rdata_SSHFP_Test
,
copy
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment