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

Fix panic parsing list definition #691

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open

Conversation

jfontan
Copy link

@jfontan jfontan commented Sep 30, 2021

This file causes panic on parse:

https://raw.githubusercontent.com/carnot-technologies/redis-scaling/master/README.md

The panic:

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

goroutine 18 [running]:
testing.tRunner.func1.2({0x52c000, 0xc0001fc000})
	/usr/lib/go/src/testing/testing.go:1209 +0x24e
testing.tRunner.func1()
	/usr/lib/go/src/testing/testing.go:1212 +0x218
panic({0x52c000, 0xc0001fc000})
	/usr/lib/go/src/runtime/panic.go:1038 +0x215
github.com/russross/blackfriday/v2.(*Markdown).listItem(0xc0001d0900, {0xc0001c3daa, 0x2c5, 0x0}, 0xc00009acd0)
	/home/jfontan/git/blackfriday/block.go:1372 +0xd9b
github.com/russross/blackfriday/v2.(*Markdown).list(0xc0001d0900, {0xc0001c3daa, 0x2c5, 0x2c6}, 0x16)
	/home/jfontan/git/blackfriday/block.go:1135 +0xdd
github.com/russross/blackfriday/v2.(*Markdown).paragraph(0xc0001d0900, {0xc0001c3d6e, 0x301, 0x302})
	/home/jfontan/git/blackfriday/block.go:1485 +0x525
github.com/russross/blackfriday/v2.(*Markdown).block(0xc0001d0900, {0xc0001c2000, 0x40cf47, 0x10})
	/home/jfontan/git/blackfriday/block.go:194 +0x671
github.com/russross/blackfriday/v2.(*Markdown).Parse(0xc0001d0900, {0xc0001c2000, 0x0, 0x0})
	/home/jfontan/git/blackfriday/markdown.go:404 +0x27
github.com/russross/blackfriday/v2.Run({0xc0001c2000, 0x206f, 0x2070}, {0x0, 0x0, 0x465cf3})
	/home/jfontan/git/blackfriday/markdown.go:388 +0x1f9
github.com/russross/blackfriday/v2.TestBadReadme(0xc000083380)
	/home/jfontan/git/blackfriday/badreadme_test.go:14 +0x98
testing.tRunner(0xc000083380, 0x5553d0)
	/usr/lib/go/src/testing/testing.go:1259 +0x102
created by testing.(*T).Run
	/usr/lib/go/src/testing/testing.go:1306 +0x35a

I've changed the code so the variable next is never larger or equal than data size. I'm not sure is the correct fix as it treats previous text to a definition list as a dl. At least it does not crash now.

koron added a commit to koron/blackfriday that referenced this pull request Mar 19, 2023
Fix panic parsing list definition
russross#691
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

Successfully merging this pull request may close these issues.

1 participant