Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/StdStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,11 @@ library stdStorageSafe {
function bytesToBytes32(bytes memory b, uint256 offset) private pure returns (bytes32) {
bytes32 out;

uint256 max = b.length > 32 ? 32 : b.length;
// Cap read length by remaining bytes from `offset`, and at most 32 bytes to avoid out-of-bounds
uint256 max = b.length > offset ? b.length - offset : 0;
if (max > 32) {
max = 32;
}
for (uint256 i = 0; i < max; i++) {
out |= bytes32(b[offset + i] & 0xFF) >> (i * 8);
}
Expand Down