Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic on listItem function #683

Open
CT-Zer0 opened this issue May 21, 2021 · 1 comment
Open

Panic on listItem function #683

CT-Zer0 opened this issue May 21, 2021 · 1 comment

Comments

@CT-Zer0
Copy link

CT-Zer0 commented May 21, 2021

Hi,

While I was fuzzing this library with go-fuzz, I am encountered with the following panic (index out of range error). I assume it is a simple size check mistake on the 1363th line of listItem function in block.go. It should be for next < len(data) - 1 && data[next] != '\n' rather than for next < len(data) && data[next] != '\n' . I have tried my patch and it works normally.

Go version:
go version go1.16.4 linux/amd64
Linux kernel:
Linux fuzz1 5.4.0-73-generic #82-Ubuntu SMP Wed Apr 14 17:39:42 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
My code (https://play.golang.org/p/lboSQ4YCIeh) :

package main

import "github.com/russross/blackfriday/v2"


func main() {

data := []byte {':','\t','\n','\n','0','\n','0','0'}
blackfriday.Run(data)

}

Error:

panic: runtime error: index out of range [8] with length 8

goroutine 1 [running]:
github.com/russross/blackfriday/v2.(*Markdown).listItem(0xc0000de900, 0xc0000143f0, 0x8, 0x8, 0xc0000addc8, 0xc000086780)
        /home/fuzz/go/pkg/mod/github.com/russross/blackfriday/[email protected]/block.go:1369 +0xedd
github.com/russross/blackfriday/v2.(*Markdown).list(0xc0000de900, 0xc0000143f0, 0x8, 0x8, 0x12, 0x0)
        /home/fuzz/go/pkg/mod/github.com/russross/blackfriday/[email protected]/block.go:1135 +0xfb
github.com/russross/blackfriday/v2.(*Markdown).block(0xc0000de900, 0xc0000143f0, 0x8, 0x8)
        /home/fuzz/go/pkg/mod/github.com/russross/blackfriday/[email protected]/block.go:187 +0x3a5
github.com/russross/blackfriday/v2.(*Markdown).Parse(0xc0000de900, 0xc0000143f0, 0x8, 0x8, 0x0)
        /home/fuzz/go/pkg/mod/github.com/russross/blackfriday/[email protected]/markdown.go:404 +0x4d
github.com/russross/blackfriday/v2.Run(0xc0000143f0, 0x8, 0x8, 0x0, 0x0, 0x0, 0x0, 0x4e4640, 0xc00005e058)
        /home/fuzz/go/pkg/mod/github.com/russross/blackfriday/[email protected]/markdown.go:388 +0x1a5
main.main()
        /home/fuzz/fuzz/deneme.go:9 +0x6b
exit status 2
@julijane
Copy link

We had the same issue in a project and the suggested change fixes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants