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

Metalnem opened this Issue Jul 20, 2017 · 1 comment


None yet
2 participants

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]:*PdfParser).parseIndirectObject(0xc420018640, 0x1000, 0x1000, 0xc420125000, 0x1000)
	/Users/Metalnem/Go/src/ +0x103b*PdfParser).lookupByNumber(0xc420018640, 0xb, 0x124cb01, 0x1600000, 0x0, 0xc420126440, 0x0, 0xc42008c180)
	/Users/Metalnem/Go/src/ +0xd1a*PdfParser).lookupByNumberWrapper(0xc420018640, 0xb, 0x1193e01, 0x17, 0xc420126440, 0x1, 0x1, 0xc420126450)
	/Users/Metalnem/Go/src/ +0x42*PdfParser).LookupByNumber(0xc420018640, 0xb, 0x17, 0xc420126440, 0x1, 0x1)
	/Users/Metalnem/Go/src/ +0x3a*PdfParser).LookupByReference(0xc420018640, 0xb, 0x0, 0xc420126410, 0x1, 0x1, 0xc4200eb6d0)
	/Users/Metalnem/Go/src/ +0xfb*PdfReader).resolveReference(0xc42007e300, 0xc42010d4f0, 0xc420126300, 0x0, 0x0, 0x1, 0x3f)
	/Users/Metalnem/Go/src/ +0x114*PdfReader).traverseObjectData(0xc42007e300, 0x12336c0, 0xc42000e160, 0xc4201263f0, 0x1)
	/Users/Metalnem/Go/src/ +0x746*PdfReader).traverseObjectData(0xc42007e300, 0x1233600, 0xc4200fb6e0, 0xc4200fb6e0, 0x0)
	/Users/Metalnem/Go/src/ +0xb1d*PdfReader).traverseObjectData(0xc42007e300, 0x1233640, 0xc4200fb620, 0x0, 0x0)
	/Users/Metalnem/Go/src/ +0x47a*PdfReader).traverseObjectData(0xc42007e300, 0x12336c0, 0xc42000e158, 0xc42010d2a0, 0x1)
	/Users/Metalnem/Go/src/ +0x8cd*PdfReader).traverseObjectData(0xc42007e300, 0x1233600, 0xc4200fb6c0, 0xc42010d270, 0x1)
	/Users/Metalnem/Go/src/ +0xb1d*PdfReader).buildPageList(0xc42007e300, 0xc4200fb6c0, 0x0, 0x5, 0xc420095708)
	/Users/Metalnem/Go/src/ +0x356*PdfReader).loadStructure(0xc42007e300, 0xc42000e000, 0x0)
	/Users/Metalnem/Go/src/ +0x652, 0xc42000e0e0, 0xc42000e0e0, 0x0, 0x0)
	/Users/Metalnem/Go/src/ +0x123
	/Users/Metalnem/Go/src/ +0x102
exit status 2

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


This comment has been minimized.

Show comment
Hide comment

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