Skip to content

Commit

Permalink
contracts: fix uint256 CBOR parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
lubej committed Jul 30, 2024
1 parent 41c4047 commit 9641422
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion contracts/contracts/Subcall.sol
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ library Subcall {
if (prefix <= 0x17) {
return (offset + 1, prefix);
}
// Byte array(uint256), parsed as a big-endian integer.
else if (prefix == 0x58) {
len = uint8(result[++offset]);
offset++;
}
// Byte array, parsed as a big-endian integer.
else if (prefix & 0x40 == 0x40) {
len = uint8(result[offset++]) ^ 0x40;
Expand All @@ -223,7 +228,7 @@ library Subcall {
revert InvalidUintPrefix(prefix);
}

if (len >= 0x20) revert InvalidLength(len);
if (len > 0x20) revert InvalidLength(len);

assembly {
value := mload(add(add(0x20, result), offset))
Expand Down

0 comments on commit 9641422

Please sign in to comment.