File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -40,9 +40,12 @@ impl FromBytes<Result<Self, &'static str>> for DnskeyRdata {
40
40
fn from_bytes ( bytes : & [ u8 ] , _full_msg : & [ u8 ] ) -> Result < Self , & ' static str > {
41
41
let bytes_len = bytes. len ( ) ;
42
42
43
- if bytes_len <= 4 {
43
+ if bytes_len <= 3 {
44
44
return Err ( "Format Error" ) ;
45
45
}
46
+ if bytes_len == 4 {
47
+ return Err ( "Public key not assigned" ) ;
48
+ }
46
49
47
50
let mut dnskey_rdata = DnskeyRdata :: new ( 0 , 0 , 0 , Vec :: new ( ) ) ;
48
51
@@ -199,12 +202,12 @@ mod dnskey_rdata_test{
199
202
dnskey_rdata. set_flags ( 1 ) ;
200
203
dnskey_rdata. set_protocol ( 2 ) ;
201
204
dnskey_rdata. set_algorithm ( 3 ) ;
202
- dnskey_rdata. set_public_key ( vec ! [ 0x01 , 0x02 ] ) ;
205
+ dnskey_rdata. set_public_key ( vec ! [ 1 , 2 ] ) ;
203
206
204
207
assert_eq ! ( dnskey_rdata. get_flags( ) , 1 ) ;
205
208
assert_eq ! ( dnskey_rdata. get_protocol( ) , 2 ) ;
206
209
assert_eq ! ( dnskey_rdata. get_algorithm( ) , 3 ) ;
207
- assert_eq ! ( dnskey_rdata. get_public_key( ) , vec![ 0x01 , 0x02 ] ) ;
210
+ assert_eq ! ( dnskey_rdata. get_public_key( ) , vec![ 1 , 2 ] ) ;
208
211
}
209
212
210
213
#[ test]
You can’t perform that action at this time.
0 commit comments