File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -330,7 +330,12 @@ fn decode_base32_hex(s: &str) -> Result<[u8; 32], KeyParsingError> {
330
330
// hex
331
331
data_encoding:: HEXLOWER . decode_mut ( s. as_bytes ( ) , & mut bytes)
332
332
} else {
333
- data_encoding:: BASE32_NOPAD . decode_mut ( s. to_ascii_uppercase ( ) . as_bytes ( ) , & mut bytes)
333
+ let input = s. to_ascii_uppercase ( ) ;
334
+ let input = input. as_bytes ( ) ;
335
+ if data_encoding:: BASE32_NOPAD . decode_len ( input. len ( ) ) ? != bytes. len ( ) {
336
+ return Err ( KeyParsingError :: DecodeInvalidLength ) ;
337
+ }
338
+ data_encoding:: BASE32_NOPAD . decode_mut ( input, & mut bytes)
334
339
} ;
335
340
match res {
336
341
Ok ( len) => {
@@ -390,4 +395,10 @@ mod tests {
390
395
key. public( )
391
396
) ;
392
397
}
398
+
399
+ #[ test]
400
+ fn test_regression_parse_node_id_panic ( ) {
401
+ let not_a_node_id = "foobarbaz" ;
402
+ assert ! ( PublicKey :: from_str( not_a_node_id) . is_err( ) ) ;
403
+ }
393
404
}
You can’t perform that action at this time.
0 commit comments