Skip to content

Commit

Permalink
tools/syz-trace2syz: add go-fuzz fuzzer
Browse files Browse the repository at this point in the history
Inputs like "2__R" or "3_F	T.3.3l" make
traze2syz hang infinitely consuming all machine memory.
Need to fix all crashes over time.
  • Loading branch information
dvyukov committed Dec 7, 2018
1 parent 742f85b commit 413e414
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tools/syz-trace2syz/proggen/fuzz.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2018 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

package proggen

import (
"github.com/google/syzkaller/prog"
_ "github.com/google/syzkaller/sys"
)

var target = func() *prog.Target {
target, err := prog.GetTarget("linux", "amd64")
if err != nil {
panic(err)
}
target.ConstMap = make(map[string]uint64)
for _, c := range target.Consts {
target.ConstMap[c.Name] = c.Value
}
return target
}()

func Fuzz(data []byte) int {
progs, err := ParseData(data, target)
if err != nil {
return 0
}
return len(progs)
}

0 comments on commit 413e414

Please sign in to comment.