From df794e72b5839571813d21657cff9994ad44b382 Mon Sep 17 00:00:00 2001 From: Emanuele Valzano <100088167+0xMenna01@users.noreply.github.com> Date: Fri, 22 Dec 2023 13:08:08 +0100 Subject: [PATCH] incrementing sufficient accounts references with saturating_add for safety. (#2768) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- substrate/frame/assets/src/functions.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/assets/src/functions.rs b/substrate/frame/assets/src/functions.rs index c2c1b6839060e..8791aaa736b35 100644 --- a/substrate/frame/assets/src/functions.rs +++ b/substrate/frame/assets/src/functions.rs @@ -77,7 +77,7 @@ impl, I: 'static> Pallet { } } else if d.is_sufficient { frame_system::Pallet::::inc_sufficients(who); - d.sufficients += 1; + d.sufficients.saturating_inc(); ExistenceReason::Sufficient } else { frame_system::Pallet::::inc_consumers(who)