aboutsummaryrefslogtreecommitdiffstats
path: root/csource/csource.go
diff options
context:
space:
mode:
authorAndrey Konovalov <andreyknvl@google.com>2016-12-02 13:18:42 +0100
committerAndrey Konovalov <andreyknvl@google.com>2016-12-02 19:21:33 +0100
commit346fb4e5e977a0f0709a4fcdf9265f163fe32459 (patch)
treedc4d42b5e2573adf997baa68ff8db038d92fbdc1 /csource/csource.go
parente4bf587846836bbdb0236d052e90af5fce3ab286 (diff)
executor: don't try to open tun if it's not enabled
Diffstat (limited to 'csource/csource.go')
-rw-r--r--csource/csource.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/csource/csource.go b/csource/csource.go
index d717ce153..8f3f99145 100644
--- a/csource/csource.go
+++ b/csource/csource.go
@@ -45,6 +45,11 @@ func Write(p *prog.Prog, opts Options) ([]byte, error) {
}
fmt.Fprintf(w, "\n")
+ enableTun := "false"
+ if _, ok := handled["syz_emit_ethernet"]; ok {
+ enableTun = "true"
+ }
+
hdr, err := preprocessCommonHeader(opts, handled)
if err != nil {
return nil, err
@@ -59,7 +64,7 @@ func Write(p *prog.Prog, opts Options) ([]byte, error) {
generateTestFunc(w, opts, calls, "loop")
fmt.Fprint(w, "int main()\n{\n")
- fmt.Fprint(w, "\tsetup_main_process(0);\n")
+ fmt.Fprintf(w, "\tsetup_main_process(0, %v);\n", enableTun)
fmt.Fprintf(w, "\tint pid = do_sandbox_%v();\n", opts.Sandbox)
fmt.Fprint(w, "\tint status = 0;\n")
fmt.Fprint(w, "\twhile (waitpid(pid, &status, __WALL) != pid) {}\n")
@@ -68,7 +73,7 @@ func Write(p *prog.Prog, opts Options) ([]byte, error) {
generateTestFunc(w, opts, calls, "test")
if opts.Procs <= 1 {
fmt.Fprint(w, "int main()\n{\n")
- fmt.Fprint(w, "\tsetup_main_process(0);\n")
+ fmt.Fprintf(w, "\tsetup_main_process(0, %v);\n", enableTun)
fmt.Fprintf(w, "\tint pid = do_sandbox_%v();\n", opts.Sandbox)
fmt.Fprint(w, "\tint status = 0;\n")
fmt.Fprint(w, "\twhile (waitpid(pid, &status, __WALL) != pid) {}\n")
@@ -78,7 +83,7 @@ func Write(p *prog.Prog, opts Options) ([]byte, error) {
fmt.Fprint(w, "\tint i;")
fmt.Fprintf(w, "\tfor (i = 0; i < %v; i++) {\n", opts.Procs)
fmt.Fprint(w, "\t\tif (fork() == 0) {\n")
- fmt.Fprint(w, "\t\t\tsetup_main_process(i);\n")
+ fmt.Fprintf(w, "\t\t\tsetup_main_process(i, %v);\n", enableTun)
fmt.Fprintf(w, "\t\t\tdo_sandbox_%v();\n", opts.Sandbox)
fmt.Fprint(w, "\t\t}\n")
fmt.Fprint(w, "\t}\n")