Skip to content

Commit c0d5a03

Browse files
committed
fix signature length issue
1 parent c25b40e commit c0d5a03

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/EIP7702Proxy.sol

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,14 @@ contract EIP7702Proxy is Proxy {
9090
}
9191
}
9292

93-
// Otherwise try ecrecover
94-
address recovered = ECDSA.recover(hash, signature);
95-
if (recovered == address(this)) {
96-
assembly {
97-
mstore(0, ERC1271_MAGIC_VALUE)
98-
return(0, 32)
93+
// Only try ECDSA if signature is the right length (65 bytes)
94+
if (signature.length == 65) {
95+
address recovered = ECDSA.recover(hash, signature);
96+
if (recovered == address(this)) {
97+
assembly {
98+
mstore(0, ERC1271_MAGIC_VALUE)
99+
return(0, 32)
100+
}
99101
}
100102
}
101103

test/EIP7702Proxy/isValidSignature.t.sol

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ contract IsValidSignatureTest is EIP7702ProxyBase {
102102
function testEmptySignature() public {
103103
bytes memory emptySignature = "";
104104

105-
vm.expectRevert();
106105
bytes4 result = wallet.isValidSignature(testHash, emptySignature);
106+
assertEq(
107+
result,
108+
ERC1271_FAIL_VALUE,
109+
"Should reject empty signature"
110+
);
107111
}
108112
}

0 commit comments

Comments
 (0)