Adjust ERC2771Context._msgData for msg.data.length < 20 (#4484)
(cherry picked from commit 9445f96223)
This commit is contained in:
committed by
Francisco Giordano
parent
7ec712baa5
commit
e4435eed75
@ -34,7 +34,7 @@ abstract contract ERC2771Context is Context {
|
||||
}
|
||||
|
||||
function _msgData() internal view virtual override returns (bytes calldata) {
|
||||
if (isTrustedForwarder(msg.sender)) {
|
||||
if (isTrustedForwarder(msg.sender) && msg.data.length >= 20) {
|
||||
return msg.data[:msg.data.length - 20];
|
||||
} else {
|
||||
return super._msgData();
|
||||
|
||||
@ -16,6 +16,12 @@ contract ContextMock is Context {
|
||||
function msgData(uint256 integerValue, string memory stringValue) public {
|
||||
emit Data(_msgData(), integerValue, stringValue);
|
||||
}
|
||||
|
||||
event DataShort(bytes data);
|
||||
|
||||
function msgDataShort() public {
|
||||
emit DataShort(_msgData());
|
||||
}
|
||||
}
|
||||
|
||||
contract ContextMockCaller {
|
||||
|
||||
Reference in New Issue
Block a user