xor-gate / goexif2 Goto Github PK
View Code? Open in Web Editor NEWThis project forked from rwcarlsen/goexif
MAINTAINER WANTED -- Decode embedded EXIF meta data from image files written in Pure Golang
License: BSD 2-Clause "Simplified" License
This project forked from rwcarlsen/goexif
MAINTAINER WANTED -- Decode embedded EXIF meta data from image files written in Pure Golang
License: BSD 2-Clause "Simplified" License
I see that the library currently support only jpeg and diff files. Are there any plans to support mp4 and other video file formats?
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 {
Hello,
The MarshalJSON() function when run on several sample images gives an:
%!(EXTRA *json.MarshalerError=json: error calling MarshalJSON for type *tiff.Tag: invalid character '!' after top-level value)
This is in response I believe to the MarkerNote: "FUJIFILM0130" !"#,012NORMAL d"
This specifically happens with the exif/samples/2009-08-05-08-11-31-sep-2009-08-05-08-11-31a.jpg as well as some others.
Any ideas on how to correct this?
Thank you!
I ran go-fuzz
on the project and found two crashes in the same line.
Input is (in hexdump):
00000000 49 49 2a 00 08 00 00 00 30 30 30 30 05 00 00 00 |II*.....0000....|
00000010 00 a0 30 30 30 30 |. 0000|
Dump:
panic: runtime error: makeslice: len out of range
goroutine 1 [running]:
github.com/xor-gate/goexif2/tiff.(*Tag).convertVals(0xc04205a280, 0xc042080480, 0xc04200e090)
/go-fuzz-build214414686/gopath/src/github.com/xor-gate/goexif2/tiff/tag.go:258 +0x88c
github.com/xor-gate/goexif2/tiff.DecodeTag(0x30a0000, 0xc042080480, 0x5605c0, 0x613170, 0x514c20, 0xc04200e06c, 0x0)
/go-fuzz-build214414686/gopath/src/github.com/xor-gate/goexif2/tiff/tag.go:182 +0x623
github.com/xor-gate/goexif2/tiff.DecodeDir(0x30a0000, 0xc042080480, 0x5605c0, 0x613170, 0xc042080480, 0x0, 0x0, 0x0)
/go-fuzz-build214414686/gopath/src/github.com/xor-gate/goexif2/tiff/tiff.go:150 +0x1c5
github.com/xor-gate/goexif2/tiff.Decode(0x560240, 0xc042080480, 0x4, 0x4, 0xc042089df0)
/go-fuzz-build214414686/gopath/src/github.com/xor-gate/goexif2/tiff/tiff.go:99 +0x548
github.com/xor-gate/goexif2/exif.Decode(0x560240, 0xc042080480, 0x5ae92fcc, 0x29751e98, 0x1e9999)
/go-fuzz-build214414686/gopath/src/github.com/xor-gate/goexif2/exif/exif.go:285 +0x330
github.com/xor-gate/goexif2/exif.Fuzz(0x3900000, 0x16, 0x200000, 0xc042047f48)
/go-fuzz-build214414686/gopath/src/github.com/xor-gate/goexif2/exif/Fuzz.go:8 +0xba
go-fuzz-dep.Main(0x550580)
/go-fuzz-build214414686/goroot/src/go-fuzz-dep/main.go:49 +0xb4
main.main()
/go-fuzz-build214414686/gopath/src/github.com/xor-gate/goexif2/exif/go.fuzz.main/main.go:10 +0x34
exit status 2
Panic happens at https://github.com/xor-gate/goexif2/blob/develop/tiff/tag.go#L258:
case DTRational:
t.ratVals = make([][]int64, int(t.Count)) // Panic
for i := range t.ratVals {
var n, d uint32
Looking at value of t.Count
before that line we see 2684354560
.
t.Count
is read further up at https://github.com/xor-gate/goexif2/blob/develop/tiff/tag.go#L133:
err = binary.Read(r, order, &t.Count)
if err != nil {
return nil, newTiffError("tag component count read failed", err)
}
Solution: We can check the value of t.Count
after reading it and discard abnormally large values. I am not familiar enough to the file format to know how large it can be. This can be merged with the check right after L133.
if t.Count == 1<<32-1 || t.Count > (1<<20-1) {
return t, newTiffError("invalid Count offset in tag", nil)
}
I've encountered several photos that have an exif LatLong entry (encoded as rationals) where one or both of the coordinates have numerator == denominator == 0. In this case exif.LatLong() returns NaN for the offending point(s).
If would be helpful if this case were handled more directly. Perhaps you could return an error in any case where the denominator is 0. Additionally, you could interpret any rational with a 0 numerator as 0.0.
This is so that when using a dependency manager, we can lock to a version and get predictable builds
Otherwise, we're sticking to a commit sha or always pulling master.
For example, using glide, we can set it to only pull certain patch/minor versions based on our comfort.
Hi, I'm currently piping my entire photo library through goexif2 and I'm running into a decode failure with the following file: https://cloud.savanne.be/apps/gallery/s/bve5feag756seDj
exif: decode failed (tiff: failed to read IFD tag count: EOF)
Exiftool does manage to decode it correctly, so it must be some kind of known bug or unhandled case.
Will look into this further later on, but pointers on how to debug this further are definitely welcome.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.