Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

Crash when exif.MakerNote is empty in Parse (Nikon) + Code to fix it #19

Open
vomnes opened this issue Jan 6, 2019 · 0 comments
Open

Comments

@vomnes
Copy link

vomnes commented Jan 6, 2019

Crash when exif.MakerNote is empty in Parse (Nikon) :

panic: runtime error: slice bounds out of range

goroutine 19 [running]:
github.com/xor-gate/goexif2/mknote.(*nikonV3).Parse(0x1443ec0, 0xc420150ea0, 0x0, 0x0)
	/Users/vomnes/go/src/github.com/xor-gate/goexif2/mknote/mknote.go:58 +0x2b4
github.com/xor-gate/goexif2/exif.Decode(0x12e6920, 0xc4204a4060, 0x2, 0x42, 0x0)
	/Users/vomnes/go/src/github.com/xor-gate/goexif2/exif/exif.go:331 +0x366

Code to fix it:

mknote/mknote.go:58
- } else if bytes.Compare(m.Val[:6], []byte("Nikon\000")) != 0 {
+ } else if len(m.Val) < 6 || bytes.Compare(m.Val[:6], []byte("Nikon\000")) != 0 {
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant