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: runtime error: makeslice: len out of range #78

Closed
Metalnem opened this Issue Jul 20, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@Metalnem

Metalnem commented Jul 20, 2017

Calling pdf.NewPdfReader on this malformed PDF file panics with the following message:

panic: runtime error: makeslice: len out of range

Stack trace:

goroutine 1 [running]:
github.com/unidoc/unidoc/pdf.(*PdfParser).parseIndirectObject(0xc420018640, 0x1000, 0x1000, 0xc420125000, 0x1000)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/pdfparser.go:1262 +0x103b
github.com/unidoc/unidoc/pdf.(*PdfParser).lookupByNumber(0xc420018640, 0xb, 0x124cb01, 0x1600000, 0x0, 0xc420126440, 0x0, 0xc42008c180)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/crossrefs.go:246 +0xd1a
github.com/unidoc/unidoc/pdf.(*PdfParser).lookupByNumberWrapper(0xc420018640, 0xb, 0x1193e01, 0x17, 0xc420126440, 0x1, 0x1, 0xc420126450)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/crossrefs.go:191 +0x42
github.com/unidoc/unidoc/pdf.(*PdfParser).LookupByNumber(0xc420018640, 0xb, 0x17, 0xc420126440, 0x1, 0x1)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/crossrefs.go:185 +0x3a
github.com/unidoc/unidoc/pdf.(*PdfParser).LookupByReference(0xc420018640, 0xb, 0x0, 0xc420126410, 0x1, 0x1, 0xc4200eb6d0)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/crossrefs.go:319 +0xfb
github.com/unidoc/unidoc/pdf.(*PdfReader).resolveReference(0xc42007e300, 0xc42010d4f0, 0xc420126300, 0x0, 0x0, 0x1, 0x3f)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/reader.go:514 +0x114
github.com/unidoc/unidoc/pdf.(*PdfReader).traverseObjectData(0xc42007e300, 0x12336c0, 0xc42000e160, 0xc4201263f0, 0x1)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/reader.go:553 +0x746
github.com/unidoc/unidoc/pdf.(*PdfReader).traverseObjectData(0xc42007e300, 0x1233600, 0xc4200fb6e0, 0xc4200fb6e0, 0x0)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/reader.go:540 +0xb1d
github.com/unidoc/unidoc/pdf.(*PdfReader).traverseObjectData(0xc42007e300, 0x1233640, 0xc4200fb620, 0x0, 0x0)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/reader.go:582 +0x47a
github.com/unidoc/unidoc/pdf.(*PdfReader).traverseObjectData(0xc42007e300, 0x12336c0, 0xc42000e158, 0xc42010d2a0, 0x1)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/reader.go:563 +0x8cd
github.com/unidoc/unidoc/pdf.(*PdfReader).traverseObjectData(0xc42007e300, 0x1233600, 0xc4200fb6c0, 0xc42010d270, 0x1)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/reader.go:540 +0xb1d
github.com/unidoc/unidoc/pdf.(*PdfReader).buildPageList(0xc42007e300, 0xc4200fb6c0, 0x0, 0x5, 0xc420095708)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/reader.go:460 +0x356
github.com/unidoc/unidoc/pdf.(*PdfReader).loadStructure(0xc42007e300, 0xc42000e000, 0x0)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/reader.go:145 +0x652
github.com/unidoc/unidoc/pdf.NewPdfReader(0x1233b80, 0xc42000e0e0, 0xc42000e0e0, 0x0, 0x0)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/reader.go:50 +0x123
main.main()
	/Users/Metalnem/Go/src/github.com/metalnem/unifuzz/main.go:19 +0x102
exit status 2

This bug was found with the help of go-fuzz.

@Metalnem

This comment has been minimized.

Show comment
Hide comment
@Metalnem

Metalnem Jul 20, 2017

Fixed in v2.

Metalnem commented Jul 20, 2017

Fixed in v2.

@Metalnem Metalnem closed this Jul 20, 2017

@gunnsth gunnsth modified the milestone: v2.0.1 Aug 3, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment