pkg/report: fix crash during output parsing

The test case causes rep.StartPos == secondReportPos,
which then makes extraction of description fail,
because report is empty.
This commit is contained in:
Dmitry Vyukov 2018-03-07 16:55:32 +01:00
parent d50edb7e5c
commit 7166783e9b
2 changed files with 15 additions and 2 deletions

View File

@ -133,10 +133,12 @@ func (ctx *linux) Parse(output []byte) *Report {
}
continue
}
rep.EndPos = next
if oops == nil {
oops = oops1
rep.StartPos = pos
rep.Title = string(output[pos+match : next])
break
} else if secondReportPos == 0 {
ignored := false
for _, ignore := range ctx.reportStartIgnores {
@ -149,7 +151,6 @@ func (ctx *linux) Parse(output []byte) *Report {
secondReportPos = pos
}
}
rep.EndPos = next
}
if oops == nil {
logReportPrefix = append(logReportPrefix, append([]byte{}, line...))
@ -221,7 +222,10 @@ func (ctx *linux) Parse(output []byte) *Report {
reportPrefix = logReportPrefix
title, corrupted, format = extractDescription(report, oops, linuxStackParams)
if title == "" {
panic(fmt.Sprintf("non matching oops for %q in:\n%s", oops.header, report))
panic(fmt.Sprintf("non matching oops for %q in:\n%s\n\nconsole:\n%s\n"+
"output [range:%v-%v]:\n%s\n",
oops.header, report, consoleReport[:firstReportEnd],
rep.StartPos, secondReportPos, output))
}
}
rep.Title = title

9
pkg/report/testdata/linux/report/217 vendored Normal file
View File

@ -0,0 +1,9 @@
TITLE: BUG: unable to handle kernel paging request in foo_ioctl
CORRUPTED: Y
foo
[ 76.470085] syz-executor7: vmalloc: allocation failure: 34359738352 bytes[ 76.471107] BUG: unable to handle kernel paging request at ffffffffa4493138
[ 76.471114] IP: [<ffffffff824164eb>] foo_ioctl+0x129b/0x2280