aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Konovalov <andreyknvl@google.com>2018-11-22 19:09:28 +0100
committerDmitry Vyukov <dvyukov@google.com>2018-11-22 19:30:04 +0100
commit87815d9d3240b653160e1eb4e5a6931c0c3bd0d9 (patch)
treecb5d55e803e88a5a878dd8cec546b1234d1af152
parent97aa259615d7b50a18f9b32a99d6dad9ffbb5cab (diff)
ipc: fix ProgInfo usage
We used to use len([]CallInfo) to check both, whether the slice is nil or whether its length is zero. Since ProgInfo is not a slice, we need a separate check for nil.
-rw-r--r--syz-fuzzer/proc.go4
-rw-r--r--tools/syz-execprog/execprog.go2
2 files changed, 3 insertions, 3 deletions
diff --git a/syz-fuzzer/proc.go b/syz-fuzzer/proc.go
index 2ad6a1720..f6b7325f5 100644
--- a/syz-fuzzer/proc.go
+++ b/syz-fuzzer/proc.go
@@ -122,7 +122,7 @@ func (proc *Proc) triageInput(item *WorkTriage) {
notexecuted := 0
for i := 0; i < signalRuns; i++ {
info := proc.executeRaw(proc.execOptsCover, item.p, StatTriage)
- if len(info.Calls) == 0 || len(info.Calls[item.call].Signal) == 0 ||
+ if info == nil || len(info.Calls) == 0 || len(info.Calls[item.call].Signal) == 0 ||
item.info.Errno == 0 && info.Calls[item.call].Errno != 0 {
// The call was not executed or failed.
notexecuted++
@@ -146,7 +146,7 @@ func (proc *Proc) triageInput(item *WorkTriage) {
func(p1 *prog.Prog, call1 int) bool {
for i := 0; i < minimizeAttempts; i++ {
info := proc.execute(proc.execOptsNoCollide, p1, ProgNormal, StatMinimize)
- if len(info.Calls) == 0 || len(info.Calls[call1].Signal) == 0 {
+ if info == nil || len(info.Calls) == 0 || len(info.Calls[call1].Signal) == 0 {
continue // The call was not executed.
}
inf := info.Calls[call1]
diff --git a/tools/syz-execprog/execprog.go b/tools/syz-execprog/execprog.go
index 1ece85c17..310492ed0 100644
--- a/tools/syz-execprog/execprog.go
+++ b/tools/syz-execprog/execprog.go
@@ -148,7 +148,7 @@ func (ctx *Context) execute(pid int, env *ipc.Env, entry *prog.LogEntry) {
log.Logf(0, "result: failed=%v hanged=%v err=%v\n\n%s",
failed, hanged, err, output)
}
- if len(info.Calls) != 0 {
+ if info == nil || len(info.Calls) != 0 {
ctx.printCallResults(info)
if *flagHints {
ctx.printHints(entry.P, info)