Skip to content

Commit

Permalink
feat: nil guards
Browse files Browse the repository at this point in the history
  • Loading branch information
IdrisHanafi committed Jun 27, 2023
1 parent 582327b commit 29ffa1c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/rpcfuzz/argfuzz/argfuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func MutateExecutor(arg []byte, c fuzz.Continue) []byte {
}

func ByteMutator(arg []byte, c fuzz.Continue) []byte {
if arg == nil {
return arg
}

arg = MutateExecutor(arg, c)
// fitty-fitty chance of more mutations
if rand.Intn(2) == 0 && arg != nil {
Expand All @@ -50,6 +54,10 @@ func ByteMutator(arg []byte, c fuzz.Continue) []byte {

func MutateRPCArgs(args *[]interface{}, c fuzz.Continue) {
for i, d := range *args {
if d == nil {
continue
}

switch d.(type) {
case string:
(*args)[i] = string(ByteMutator([]byte(d.(string)), c))
Expand Down

0 comments on commit 29ffa1c

Please sign in to comment.