Can parameter overflow be prevented in the contract, or does it have to be dealt with on the frontend?
Solidity:
contract parameterOverflows {
uint8 selectedCharacter;
modifier onlyCharacter(uint8 _character) {
require(_character < 256);
_;
}
function selectCharacter(uint8 _character) public onlyCharacter(_character) {
selectedCharacter = _character;
}
}
If selectCharacter(257) is called, selectedCharacter becomes 1 because (I think) the 257 overflows to 1.
This could be prevented by just not calling the function with anything outside the intended range, but is it possible to prevent this from the contract? Where exactly is the overflow happening?