aboutsummaryrefslogtreecommitdiffstats
path: root/tools/syz-prog2c/prog2c.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-12-09 17:08:14 +0100
committerDmitry Vyukov <dvyukov@google.com>2018-12-10 16:37:01 +0100
commit95fe19c19e596446412626b048d950de6ce8c886 (patch)
tree4dc35d5dc26acf7a3fa78eafdda07bbd283b2bcc /tools/syz-prog2c/prog2c.go
parenta5efea3ec3e302da3fa01ca44604fe62aec49a79 (diff)
prog: introduce strict parsing mode
Over time we relaxed parsing to handle all kinds of invalid programs (excessive/missing args, wrong types, etc). This is useful when reading old programs from corpus. But this is harmful for e.g. reading test inputs as they can become arbitrary outdated. For runtests which creates additional problem of executing not what is actually written in the test (or at least what author meant). Add strict parsing mode that does not tolerate any errors. For now it just checks excessive syscall arguments.
Diffstat (limited to 'tools/syz-prog2c/prog2c.go')
-rw-r--r--tools/syz-prog2c/prog2c.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/syz-prog2c/prog2c.go b/tools/syz-prog2c/prog2c.go
index 6abbd68b4..d45c1e5a8 100644
--- a/tools/syz-prog2c/prog2c.go
+++ b/tools/syz-prog2c/prog2c.go
@@ -34,6 +34,7 @@ var (
flagResetNet = flag.Bool("resetnet", false, "reset net namespace after each test")
flagHandleSegv = flag.Bool("segv", false, "catch and ignore SIGSEGV")
flagTrace = flag.Bool("trace", false, "trace syscall results")
+ flagStrict = flag.Bool("strict", false, "parse input program in strict mode")
)
func main() {
@@ -52,7 +53,11 @@ func main() {
fmt.Fprintf(os.Stderr, "failed to read prog file: %v\n", err)
os.Exit(1)
}
- p, err := target.Deserialize(data)
+ mode := prog.NonStrict
+ if *flagStrict {
+ mode = prog.Strict
+ }
+ p, err := target.Deserialize(data, mode)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to deserialize the program: %v\n", err)
os.Exit(1)