Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Overflow/underflow handling (15 - Minor) #53

Closed
ansermino opened this issue May 26, 2020 · 0 comments · Fixed by #58
Closed

Overflow/underflow handling (15 - Minor) #53

ansermino opened this issue May 26, 2020 · 0 comments · Fixed by #58
Assignees

Comments

@ansermino
Copy link
Member

Substrate does not have default overflow/underflow protection. In order to avoid this kind of bugs, it’s better to use safe functions like checked_add() and checked_sub(). In the current codebase math operations are mostly either incrementing (+1) or making operations with values that shouldn’t overflow/underflow logically:

chainbridge/src/lib.rs:L64

} else if self.votes_against.len() > (total - threshold) as usize {

It’s not really a big issue here, but if the threshold is bigger than the total, we’ll have underflow.

@ansermino ansermino changed the title Overflow/underflow handling (5.15 - Minor) Overflow/underflow handling (15 - Minor) Jun 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant