incrementing sufficient accounts references with saturating_add for safety. (#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>
This commit is contained in:
Emanuele Valzano
2023-12-22 13:08:08 +01:00
committed by GitHub
parent b62df69592
commit 0ce506ef1b
+1 -1
View File
@@ -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)