Skip to content

Commit

Permalink
Add function selector check for slow vm
Browse files Browse the repository at this point in the history
  • Loading branch information
mininny committed Dec 15, 2024
1 parent 8ff9318 commit c9a7813
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rvgo/slow/vm.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package slow

import (
"bytes"
"encoding/binary"
"fmt"

Expand Down Expand Up @@ -121,6 +122,11 @@ func Step(calldata []byte, po PreimageOracle) (stateHash common.Hash, outErr err
return
}

expectedSelector := []byte{0xe1, 0x4c, 0xed, 0x32}
if len(calldata) < 4 || !bytes.Equal(calldata[:4], expectedSelector) {
panic("invalid function selector")
}

stateContentOffset := uint8(4 + 32 + 32 + 32 + 32)
if iszero(eq(b32asBEWord(calldataload(toU64(4+32*3))), shortToU256(stateSize))) {
// user-provided state size must match expected state size
Expand Down

0 comments on commit c9a7813

Please sign in to comment.