Skip to content

Commit

Permalink
incrementing sufficient accounts references with saturating_add for s…
Browse files Browse the repository at this point in the history
…afety. (paritytech#2768)

Even though it is difficult to overflow the sufficients variable, since
an attacker that is willing to rapidly increase the number must every
time deposit a minimum deposit of a given asset, it is safer to use
saturating_add().

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 22, 2023
1 parent 979aff2 commit df794e7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion substrate/frame/assets/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
}
} else if d.is_sufficient {
frame_system::Pallet::<T>::inc_sufficients(who);
d.sufficients += 1;
d.sufficients.saturating_inc();
ExistenceReason::Sufficient
} else {
frame_system::Pallet::<T>::inc_consumers(who)
Expand Down

0 comments on commit df794e7

Please sign in to comment.