Description: The HorseStore::FEED_HORSE
function contains a modulo 17 conditional check that can cause the function to revert depending
on the block.timestamp
#define macro FEED_HORSE() = takes (0) returns (0) {
timestamp
0x04 calldataload
STORE_ELEMENT(0x00)
@> 0x11 timestamp mod
@> endFeed jumpi
revert
endFeed:
stop
}
Impact: High, the HorseStore::FEED_HORSE
function should not revert under any circumstance
Proof 0f Code:
Code
add test to HorseStoreHuff.t.sol
function test_feedHorseFail(uint timestamp) public {
vm.assume((timestamp % 17) == 0);
vm.warp(timestamp);
uint256 horseId = horseStore.totalSupply();
vm.prank(user);
horseStore.mintHorse();
vm.expectRevert();
horseStore.feedHorse(horseId);
}
Recommendation:
#define macro FEED_HORSE() = takes (0) returns (0) {
timestamp // [timestamp]
0x04 calldataload // [horseId, timestamp]
STORE_ELEMENT(0x00) // []
// End execution
- 0x11 timestamp mod //? [timestamp % 17] why
- endFeed jumpi //? feeding the horse should not revert for any reason
- revert
- endFeed:
stop
}