Skip to content

Commit

Permalink
core/vm, crypto: support for go-fuzz (#3672)
Browse files Browse the repository at this point in the history
  • Loading branch information
obscuren authored Feb 21, 2017
1 parent 94334c2 commit 4ac481b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions core/vm/runtime/fuzz.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// +build gofuzz

package runtime

// Fuzz is the basic entry point for the go-fuzz tool
//
// This returns 1 for valid parsable/runable code, 0
// for invalid opcode.
func Fuzz(input []byte) int {
_, _, err := Execute(input, input, &Config{
GasLimit: 3000000,
})

// invalid opcode
if err != nil && len(err.Error()) > 6 && string(err.Error()[:7]) == "invalid" {
return 0
}

return 1
}

0 comments on commit 4ac481b

Please sign in to comment.