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: invalid memory address or nil pointer dereference #79

Closed
Metalnem opened this Issue Jul 20, 2017 · 6 comments

Comments

Projects
None yet
3 participants
@Metalnem

Metalnem commented Jul 20, 2017

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

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x111a985]

Stack trace:

goroutine 1 [running]:
github.com/unidoc/unidoc/pdf.(*PdfParser).Trace(0xc420018640, 0x1233800, 0xc42016bc40, 0x0, 0x0, 0x0, 0x0)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/crossrefs.go:339 +0x125
github.com/unidoc/unidoc/pdf.(*PdfParser).parseIndirectObject(0xc420018640, 0x1000, 0x1000, 0xc42016d000, 0x1000)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/pdfparser.go:1246 +0xe7c
github.com/unidoc/unidoc/pdf.(*PdfParser).lookupByNumber(0xc420018640, 0x10b, 0xc420108000, 0x1167c20, 0xc420168500, 0xc420108010, 0xc4200e8d77, 0xc420014e10)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/crossrefs.go:246 +0xd1a
github.com/unidoc/unidoc/pdf.(*PdfParser).lookupByNumberWrapper(0xc420018640, 0x10b, 0xc420049900, 0xc4200e8f08, 0xc420168500, 0x0, 0x0, 0x0)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/crossrefs.go:191 +0x42
github.com/unidoc/unidoc/pdf.(*PdfParser).rebuildXrefTable(0xc420018640, 0x11946de, 0x19)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/repairs.go:51 +0x130
github.com/unidoc/unidoc/pdf.(*PdfParser).lookupByNumber(0xc420018640, 0xdd, 0x124cb01, 0x1500000, 0x0, 0xc420132010, 0x0, 0xc42008c180)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/crossrefs.go:270 +0x1282
github.com/unidoc/unidoc/pdf.(*PdfParser).lookupByNumberWrapper(0xc420018640, 0xdd, 0x1193e01, 0x17, 0xc420132010, 0x1, 0x1, 0xc420132020)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/crossrefs.go:191 +0x42
github.com/unidoc/unidoc/pdf.(*PdfParser).LookupByNumber(0xc420018640, 0xdd, 0x17, 0xc420132010, 0x1, 0x1)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/crossrefs.go:185 +0x3a
github.com/unidoc/unidoc/pdf.(*PdfParser).LookupByReference(0xc420018640, 0xdd, 0x0, 0x4, 0xc420095178, 0x14, 0x14)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/crossrefs.go:319 +0xfb
github.com/unidoc/unidoc/pdf.(*PdfReader).loadStructure(0xc42007e300, 0xc42000e000, 0x0)
	/Users/Metalnem/Go/src/github.com/unidoc/unidoc/pdf/reader.go:95 +0xd8
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.

@ahall

This comment has been minimized.

Show comment
Hide comment
@ahall

ahall Jul 20, 2017

Contributor

Thanks for filing this. Are you trying this against the master or the v2 branch? We are releasing version 2 very shortly and it contains a lot of changes to the current master. We aim to merge this very soon.

Contributor

ahall commented Jul 20, 2017

Thanks for filing this. Are you trying this against the master or the v2 branch? We are releasing version 2 very shortly and it contains a lot of changes to the current master. We aim to merge this very soon.

@Metalnem

This comment has been minimized.

Show comment
Hide comment
@Metalnem

Metalnem Jul 20, 2017

I'm running this against master branch.

Metalnem commented Jul 20, 2017

I'm running this against master branch.

@ahall

This comment has been minimized.

Show comment
Hide comment
@ahall

ahall Jul 20, 2017

Contributor

Can you try this against the v2 branch please?

Contributor

ahall commented Jul 20, 2017

Can you try this against the v2 branch please?

@Metalnem

This comment has been minimized.

Show comment
Hide comment
@Metalnem

Metalnem Jul 20, 2017

Same thing in v2.

Metalnem commented Jul 20, 2017

Same thing in v2.

@ahall

This comment has been minimized.

Show comment
Hide comment
@ahall

ahall Jul 20, 2017

Contributor

Thanks for this, we will have a look at this.

Contributor

ahall commented Jul 20, 2017

Thanks for this, we will have a look at this.

@gunnsth gunnsth added the bug label Jul 20, 2017

@gunnsth

This comment has been minimized.

Show comment
Hide comment
@gunnsth

gunnsth Jul 21, 2017

Contributor

This has been resolved in commit
5f506b7

Contributor

gunnsth commented Jul 21, 2017

This has been resolved in commit
5f506b7

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