-
Notifications
You must be signed in to change notification settings - Fork 24
/
fuzz_test.go
100 lines (97 loc) · 2.17 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
93
94
95
96
97
98
99
100
package ndp
import "testing"
func Test_fuzz(t *testing.T) {
tests := []struct {
name string
s string
}{
{
name: "parse option length",
s: "\x86000000000000000\x01\xc0",
},
{
name: "prefix information length",
s: "\x86000000000000000\x03\x0100" +
"0000",
},
{
name: "raw option marshal symmetry",
s: "\x860000000000000000!00" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000",
},
{
name: "rdnss no servers",
s: "\x850000000\x19\x01000000",
},
{
name: "dnssl bad domain",
s: "\x850000000\x1f\x02000000\x02.0\x01" +
"0\x00\x000",
},
{
name: "dnssl length padding",
s: "\x86000000000000000\x1f\b00" +
"0000\x010\x010\x010\x1d000000000" +
"00000000000000000000" +
"\x010\x010\x00\x0000000000000000",
},
{
name: "dnssl early termination no padding",
s: "\x850000000\x1f\f000000\x010\x010" +
"\x0200\x00\x00000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"0000",
},
{
name: "dnssl early termination one pad null",
s: "\x850000000\x1f\a000000\x0200\x00" +
"\t000000000\x00\x0000000000" +
"00000000000000000000" +
"0000",
},
{
name: "dnssl punycode empty string",
s: "\x850000000\x1f\x02000000\x04xn-" +
"-\x00\x000",
},
{
name: "dnssl with spaces",
s: "\x850000000\x1f\x03000000\x05." +
"00\x010\x0500000\x00\x00",
},
{
name: "dnssl not ASCII",
s: "\x850000000\x1f\x02000000\x06." +
"000\x00",
},
{
name: "dnssl decodes to empty string",
s: "\x850000000\x1f\x02000000\x04xn-" +
"-\x010\x00",
},
{
name: "dnssl unicode replacement character",
s: "\x850000000\x1f\x04000000\x010\x020" +
"0\x0exn---00000H00F\x01@\x00\x00",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_ = fuzz([]byte(tt.s))
})
}
}