diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2015-12-17 16:06:33 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2015-12-17 16:06:33 +0100 |
| commit | 8e7ca7c5ff18e17cab7b6b3ae569565224f95fcc (patch) | |
| tree | 613bbb3f12f7f2f63ad225648f6971a1393d3703 /tools/syz-mutate | |
| parent | 06e67265374faa677dba2dbd2577054278f19823 (diff) | |
remove master and naming overhaul
Remove master process entirely, it is not useful in its current form.
We first need to understand what we want from it, and them re-implement it.
Prefix all binaries with syz- to avoid name clashes.
Diffstat (limited to 'tools/syz-mutate')
| -rw-r--r-- | tools/syz-mutate/mutate.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tools/syz-mutate/mutate.go b/tools/syz-mutate/mutate.go new file mode 100644 index 000000000..353d60390 --- /dev/null +++ b/tools/syz-mutate/mutate.go @@ -0,0 +1,49 @@ +// Copyright 2015 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. + +// mutates mutates a given program and prints result. +package main + +import ( + "flag" + "fmt" + "io/ioutil" + "math/rand" + "os" + "time" + + "github.com/google/syzkaller/prog" +) + +var ( + flagSeed = flag.Int("seed", -1, "prng seed") +) + +func main() { + flag.Parse() + if flag.NArg() != 1 { + fmt.Fprintf(os.Stderr, "usage: mutate program\n") + os.Exit(1) + } + data, err := ioutil.ReadFile(flag.Arg(0)) + if err != nil { + fmt.Fprintf(os.Stderr, "failed to read prog file: %v\n", err) + os.Exit(1) + } + p, err := prog.Deserialize(data) + if err != nil { + fmt.Fprintf(os.Stderr, "failed to deserialize the program: %v\n", err) + os.Exit(1) + } + + prios := prog.CalculatePriorities(nil) + ct := prog.BuildChoiceTable(prios, nil) + + seed := time.Now().UnixNano() + if *flagSeed != -1 { + seed = int64(*flagSeed) + } + rs := rand.NewSource(seed) + p.Mutate(rs, len(p.Calls)+10, ct) + fmt.Printf("%s\n", p.Serialize()) +} |
