mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-14 15:10:13 +00:00
overflow check
This commit is contained in:
@@ -30,14 +30,17 @@ pub fn process_update_tolerance<'a, 'info>(
|
||||
return Err(ProgramError::MissingRequiredSignature);
|
||||
}
|
||||
|
||||
// Overflow checks
|
||||
if args.tolerance_liveness.gt(&(i64::MAX as u64)) {
|
||||
return Err(OreError::ToleranceInvalid.into());
|
||||
}
|
||||
if args.tolerance_spam.gt(&(i64::MAX as u64)) {
|
||||
return Err(OreError::ToleranceInvalid.into());
|
||||
}
|
||||
|
||||
// Update tolerances
|
||||
config.tolerance_liveness = args.tolerance_liveness as i64;
|
||||
config.tolerance_spam = args.tolerance_spam as i64;
|
||||
|
||||
// Sanity checks
|
||||
if config.tolerance_liveness.lt(&0) || config.tolerance_spam.lt(&0) {
|
||||
return Err(OreError::ToleranceNegative.into());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user