aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/syz-trace2syz/proggen/fuzz.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/syz-trace2syz/proggen/fuzz.go b/tools/syz-trace2syz/proggen/fuzz.go
new file mode 100644
index 000000000..d80acb4f0
--- /dev/null
+++ b/tools/syz-trace2syz/proggen/fuzz.go
@@ -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)
+}