Add upfront length checks to confid
This commit is contained in:
parent
61d875757d
commit
d00fbb9882
1 changed files with 6 additions and 0 deletions
|
@ -21,6 +21,12 @@ pub enum ConfirmationIdError {
|
|||
}
|
||||
|
||||
pub fn generate(installation_id: &str) -> Result<String, ConfirmationIdError> {
|
||||
if installation_id.len() < 54 {
|
||||
return Err(ConfirmationIdError::TooShort);
|
||||
}
|
||||
if installation_id.len() > 54 {
|
||||
return Err(ConfirmationIdError::TooLarge);
|
||||
}
|
||||
let inst_id = CString::new(installation_id).unwrap();
|
||||
let conf_id = [0u8; 49];
|
||||
let result = unsafe { black_box::generate(inst_id.as_ptr(), conf_id.as_ptr() as *mut i8) };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue