Skip to content

Commit ca161f1

Browse files
committed
fix: check hex len validatorId
1 parent 6136ae2 commit ca161f1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

primitives/src/validator.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ impl TryFrom<&str> for ValidatorId {
4848
let result = hex::decode(hex_value).map_err(|_| {
4949
DomainError::InvalidArgument("Failed to deserialize validator id".to_string())
5050
})?;
51+
52+
if result.len() != 20 {
53+
return Err(DomainError::InvalidArgument(format!(
54+
"Invalid validator id value {}",
55+
value
56+
)));
57+
}
58+
5159
let mut id: [u8; 20] = [0; 20];
5260
id.copy_from_slice(&result[..]);
5361
Ok(Self(id))

0 commit comments

Comments
 (0)