Skip to content

Commit

Permalink
fix: change int underflow for uint256 max
Browse files Browse the repository at this point in the history
  • Loading branch information
0xAustrian committed May 3, 2024
1 parent 802cf48 commit 7b96a5a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/contracts/BToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ contract BToken is BTokenBase {
function transferFrom(address src, address dst, uint amt) external override returns (bool) {
require(msg.sender == src || amt <= _allowance[src][msg.sender], "ERR_BTOKEN_BAD_CALLER");
_move(src, dst, amt);
if (msg.sender != src && _allowance[src][msg.sender] != uint256(int(-1))) {
if (msg.sender != src && _allowance[src][msg.sender] != type(uint256).max) {
_allowance[src][msg.sender] = bsub(_allowance[src][msg.sender], amt);
emit Approval(msg.sender, dst, _allowance[src][msg.sender]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/test/TToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ contract TToken {
function transferFrom(address src, address dst, uint amt) external returns (bool) {
require(msg.sender == src || amt <= _allowance[src][msg.sender], "ERR_BTOKEN_BAD_CALLER");
_move(src, dst, amt);
if (msg.sender != src && _allowance[src][msg.sender] != uint256(int(-1))) {
if (msg.sender != src && _allowance[src][msg.sender] != type(uint256).max) {
_allowance[src][msg.sender] = sub(_allowance[src][msg.sender], amt);
emit Approval(msg.sender, dst, _allowance[src][msg.sender]);
}
Expand Down

0 comments on commit 7b96a5a

Please sign in to comment.