Add upfront length checks to confid

This commit is contained in:
Alex Page 2023-06-23 16:59:02 -04:00
parent 61d875757d
commit d00fbb9882

View file

@ -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) };