From 7b96a5ade9a9a573a5a055e019941e22a6df6fa8 Mon Sep 17 00:00:00 2001 From: 0xAustrian Date: Fri, 3 May 2024 09:47:17 -0300 Subject: [PATCH] fix: change int underflow for uint256 max --- src/contracts/BToken.sol | 2 +- src/contracts/test/TToken.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/contracts/BToken.sol b/src/contracts/BToken.sol index 1ffdb9a1..736a30b5 100644 --- a/src/contracts/BToken.sol +++ b/src/contracts/BToken.sol @@ -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]); } diff --git a/src/contracts/test/TToken.sol b/src/contracts/test/TToken.sol index 43016640..d9134492 100644 --- a/src/contracts/test/TToken.sol +++ b/src/contracts/test/TToken.sol @@ -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]); }