mirror of https://github.com/dsoprea/go-exif.git
Collect goes into an infinite loop for a broken jpg file
parent
d154f10435
commit
827ecdad3d
Binary file not shown.
After Width: | Height: | Size: 107 KiB |
|
@ -2,15 +2,14 @@ package exif
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"encoding/binary"
|
|
||||||
"io/ioutil"
|
|
||||||
|
|
||||||
"github.com/dsoprea/go-logging"
|
"github.com/dsoprea/go-logging"
|
||||||
|
|
||||||
"github.com/dsoprea/go-exif/v3/common"
|
"github.com/dsoprea/go-exif/v3/common"
|
||||||
|
@ -409,6 +408,31 @@ func TestExif_BuildAndParseExifHeader(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestExif_ParseBrokenExif(t *testing.T) {
|
||||||
|
file, err := os.Open(getTestBrokenExifFilepath())
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
rawExif, err := SearchAndExtractExifWithReader(file)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ifd, err := exifcommon.NewIfdMappingWithStandard()
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tag := NewTagIndex()
|
||||||
|
_, _, err = Collect(ifd, tag, rawExif)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func ExampleBuildExifHeader() {
|
func ExampleBuildExifHeader() {
|
||||||
headerBytes, err := BuildExifHeader(exifcommon.TestDefaultByteOrder, 0x11223344)
|
headerBytes, err := BuildExifHeader(exifcommon.TestDefaultByteOrder, 0x11223344)
|
||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
|
|
@ -186,3 +186,9 @@ func getTestGeotiffFilepath() string {
|
||||||
testGeotiffFilepath := path.Join(assetsPath, "geotiff_example.tif")
|
testGeotiffFilepath := path.Join(assetsPath, "geotiff_example.tif")
|
||||||
return testGeotiffFilepath
|
return testGeotiffFilepath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getTestBrokenExifFilepath() string {
|
||||||
|
assetsPath := exifcommon.GetTestAssetsPath()
|
||||||
|
testBrokenExifFilepath := path.Join(assetsPath, "broken_exif.jpg")
|
||||||
|
return testBrokenExifFilepath
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue