forked from rwcarlsen/goexif
-
Notifications
You must be signed in to change notification settings - Fork 1
/
fuzz_test.go
92 lines (80 loc) · 2.91 KB
/
fuzz_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package goexif
import (
"bytes"
"testing"
"github.com/hmage/goexif/exif"
"github.com/hmage/goexif/mknote"
)
func TestFuzzCrash1(t *testing.T) {
exif.RegisterParsers(mknote.All...)
input := []byte("II*\x00\t\x00\x00\x00\x00if\xcfe\t\x00\x02\x00\x00\xc0")
result, err := exif.Decode(bytes.NewReader(input))
if err.Error() != "exif: decode failed (invalid Count offset in tag) " {
t.Fatalf("expected invalid count offset error but got: %q", err.Error())
}
t.Log(result)
}
func TestFuzzCrash2(t *testing.T) {
exif.RegisterParsers(mknote.All...)
input := []byte("MM\x00*\x00\x00\x00@\xbd\xbf\x01\x00\x00\x00\x00\xbd\xbf/\xbd\xbf" +
"\xefY\xef\x02\x00\x00\x00\x01\x00\x00*\x00\x00\x00\x00\x00\x00\x00\x00 " +
"\x00\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x01*\x00\x00\x8d\b\x00\x00\x03" +
"\x00\x00\x00*\x00\x00\x00\x00\x00*")
result, err := exif.Decode(bytes.NewReader(input))
if err.Error() != "exif: decode failed (tiff: recursive IFD) " {
t.Fatalf("expected resursive IFD error but got: %q", err.Error())
}
t.Log(result)
}
func TestFuzzCrash3(t *testing.T) {
exif.RegisterParsers(mknote.All...)
input := []byte("MM\x00*\x00\x00\x00\b\xd5\x02\x00\x00\x00\x19\xe3\xfd \x00\x00\x00" +
"\x02\x00\x00\x00\x01՛\x00\x00\x00\b\xe3")
result, err := exif.Decode(bytes.NewReader(input))
if err.Error() != "exif: decode failed (tiff: recursive IFD) " {
t.Fatalf("expected resursive IFD error but got: %q", err.Error())
}
t.Log(result)
}
func TestFuzzCrash4(t *testing.T) {
exif.RegisterParsers(mknote.All...)
input := []byte("II*\x00\b\x00\x00\x00\t\x000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"000000i\x87\x04\x00\x01\x00\x00\x00\xac\x00\x00\x0000" +
"00000000000000000000" +
"00000000000000000000" +
"0000000000000000\x05\x00\x00\x00" +
"\x00\xe00000")
result, err := exif.Decode(bytes.NewReader(input))
if err.Error() != "exif: decode failed (tiff: seek offset after EOF) " {
t.Fatalf("expected seek offset after EOF error but got: %q", err.Error())
}
t.Log(result)
}
func TestFuzzCrash5(t *testing.T) {
exif.RegisterParsers(mknote.All...)
input := []byte("MM\x00*\x00\x00\x00\b\x00\a0000000000" +
"00000000000000000000" +
"000000000000000000\x87i" +
"\x00\x04\x00\x00\x00\x0000000000000000" +
"00000000000000000000" +
"00000000000000")
result, err := exif.Decode(bytes.NewReader(input))
if err.Error() != "exif: decode failed (tiff: seek offset after EOF) " {
t.Fatalf("expected seek offset after EOF error but got: %q", err.Error())
}
t.Log(result)
}
func TestFuzzCrash6(t *testing.T) {
exif.RegisterParsers(mknote.All...)
input := []byte("II*\x00\b\x00\x00\x000000\x05\x00\x00\x00\x00\xa000" +
"00")
result, err := exif.Decode(bytes.NewReader(input))
if err.Error() != "exif: decode failed (invalid Count offset in tag) " {
t.Fatalf("expected invalid Count offset error but got: %q", err.Error())
}
t.Log(result)
}